Properly close the ALSA output device when stopped. Fixes a high CPU usage bug in Linux.

This commit is contained in:
clangen 2016-06-10 00:29:45 -07:00
parent 1a65eaa0e6
commit 509423a43a

View File

@ -47,7 +47,6 @@
#define CHECK_QUIT() if (this->quit) { return; }
#define PRINT_ERROR(x) std::cerr << "AlsaOut: error! " << snd_strerror(x) << std::endl;
#define WRITE_BUFFER(handle, context, samples) \
err = snd_pcm_writei(handle, context->buffer->BufferPointer(), samples); \
if (err < 0) { PRINT_ERROR(err); }
@ -165,7 +164,11 @@ void AlsaOut::Stop() {
if (this->pcmHandle) {
snd_pcm_drop(this->pcmHandle);
snd_pcm_prepare(this->pcmHandle);
if (this->pcmHandle) {
snd_pcm_close(this->pcmHandle);
this->pcmHandle = NULL;
}
}
}