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,12 +418,17 @@ void AlsaOut::WriteLoop() {
}
}
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel); /* sets 'err' */
{
LOCK("WRITE_BUFFER()");
if (this->pcmHandle) {
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel); /* sets 'err' */
if (err == -EINTR || err == -EPIPE || err == -ESTRPIPE) {
if (!snd_pcm_recover(this->pcmHandle, err, 1)) {
/* try one more time... */
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel);
if (err == -EINTR || err == -EPIPE || err == -ESTRPIPE) {
if (!snd_pcm_recover(this->pcmHandle, err, 1)) {
/* try one more time... */
WRITE_BUFFER(this->pcmHandle, next, samplesPerChannel);
}
}
}
}