Yikes, found a pretty nasty race condition in AlsaOut. This should

stabilize things.
This commit is contained in:
casey langen 2020-04-08 20:56:32 -07:00
parent 5cbdea7b1e
commit 0e6e96b58f

View File

@ -165,6 +165,7 @@ AlsaOut::~AlsaOut() {
}
void AlsaOut::CloseDevice() {
LOCK("CloseDevice()");
if (this->pcmHandle) {
std::cerr << "AlsaOut: closing PCM handle\n";
snd_pcm_close(this->pcmHandle);
@ -417,6 +418,9 @@ void AlsaOut::WriteLoop() {
}
}
{
LOCK("WRITE_BUFFER()");
if (this->pcmHandle) {
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel); /* sets 'err' */
if (err == -EINTR || err == -EPIPE || err == -ESTRPIPE) {
@ -425,6 +429,8 @@ void AlsaOut::WriteLoop() {
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel);
}
}
}
}
if (err > 0 && err < (int) samplesPerChannel) {
std::cerr << "AlsaOut: short write. expected=" << samplesPerChannel << ", actual=" << err << std::endl;