mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-04 00:36:01 +00:00
Improve ALSA underrun error recovery
Fixes lack of audio on Vero 4K
This commit is contained in:
parent
58958ca32a
commit
cb4b5d55b5
@ -115,14 +115,17 @@ static void alsa_renderer_decode_and_play_sample(char* data, int length) {
|
|||||||
int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, samplesPerFrame, 0);
|
int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, samplesPerFrame, 0);
|
||||||
if (decodeLen > 0) {
|
if (decodeLen > 0) {
|
||||||
int rc = snd_pcm_writei(handle, pcmBuffer, decodeLen);
|
int rc = snd_pcm_writei(handle, pcmBuffer, decodeLen);
|
||||||
if (rc == -EPIPE)
|
if (rc < 0) {
|
||||||
snd_pcm_recover(handle, rc, 1);
|
rc = snd_pcm_recover(handle, rc, 0);
|
||||||
|
if (rc == 0)
|
||||||
|
rc = snd_pcm_writei(handle, pcmBuffer, decodeLen);
|
||||||
|
}
|
||||||
|
|
||||||
if (rc<0)
|
if (rc<0)
|
||||||
printf("Alsa error from writei: %d\n", rc);
|
printf("Alsa error from writei: %d\n", rc);
|
||||||
else if (decodeLen != rc)
|
else if (decodeLen != rc)
|
||||||
printf("Alsa shortm write, write %d frames\n", rc);
|
printf("Alsa shortm write, write %d frames\n", rc);
|
||||||
} else {
|
} else if (decodeLen < 0) {
|
||||||
printf("Opus error from decode: %d\n", decodeLen);
|
printf("Opus error from decode: %d\n", decodeLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user