mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Added recover logic to AlsaOut.
This commit is contained in:
parent
2cfba1ff56
commit
4cd247ad16
@ -47,6 +47,11 @@
|
|||||||
#define CHECK_QUIT() if (this->quit) { return; }
|
#define CHECK_QUIT() if (this->quit) { return; }
|
||||||
#define PRINT_ERROR(x) std::cerr << "AlsaOut: error! " << snd_strerror(x) << std::endl;
|
#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); }
|
||||||
|
|
||||||
using namespace musik::core::audio;
|
using namespace musik::core::audio;
|
||||||
|
|
||||||
AlsaOut::AlsaOut()
|
AlsaOut::AlsaOut()
|
||||||
@ -222,6 +227,7 @@ void AlsaOut::WriteLoop() {
|
|||||||
size_t samples = next->buffer->Samples();
|
size_t samples = next->buffer->Samples();
|
||||||
size_t channels = next->buffer->Channels();
|
size_t channels = next->buffer->Channels();
|
||||||
|
|
||||||
|
|
||||||
float volume = (float) this->volume;
|
float volume = (float) this->volume;
|
||||||
|
|
||||||
/* software volume; alsa doesn't support this internally. this is about
|
/* software volume; alsa doesn't support this internally. this is about
|
||||||
@ -232,17 +238,13 @@ void AlsaOut::WriteLoop() {
|
|||||||
++buffer;
|
++buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_writei(
|
WRITE_BUFFER(this->pcmHandle, next, samples); /* sets 'err' */
|
||||||
this->pcmHandle,
|
|
||||||
next->buffer->BufferPointer(),
|
|
||||||
samples);
|
|
||||||
|
|
||||||
// if (err < 0) {
|
if (err == -EINTR || err == -EPIPE || err == -ESTRPIPE) {
|
||||||
// err = snd_pcm_recover(this->pcmHandle, samples, 0);
|
if (!snd_pcm_recover(this->pcmHandle, err, 1)) {
|
||||||
// }
|
/* try one more time... */
|
||||||
|
WRITE_BUFFER(this->pcmHandle, next, samples);
|
||||||
if (err < 0) {
|
}
|
||||||
PRINT_ERROR(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err > 0 && err < (int) samples) {
|
if (err > 0 && err < (int) samples) {
|
||||||
|
Loading…
Reference in New Issue
Block a user