ALSA: Fix an error with underrun recovery.

When an underrun occurs the buffer needs to be filled with data before
restarting or else snd_pcm_start() will return EPIPE.
This commit is contained in:
David Reid
2026-01-13 10:36:30 +10:00
parent 55cdba084d
commit 98a23f9551
+6
View File
@@ -29833,6 +29833,12 @@ static ma_result ma_device_step__alsa(ma_device* pDevice, ma_blocking_mode block
return ma_result_from_errno((int)-resultALSA);
}
/*
Before restarting the PCM we need to make sure there's actually some data in the buffer. We're going to
fill it with silence which is consistent with what we do when we start the PCM normally.
*/
ma_device_prime_playback_buffer__alsa(pDevice);
resultALSA = pContextStateALSA->snd_pcm_start(pDeviceStateALSA->pPCMPlayback);
if (resultALSA < 0) {
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start playback device after underrun. %s.", pContextStateALSA->snd_strerror(resultALSA));