Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alsa: Use
snd_pcm_pause()
, recover from buffer underruns
Currently the plugout_alsa "pauses" playback simply by ceasing to call `snd_pcm_writei()`; this causes a buffer underrun error on resuming playback, and omission of one buffer's worth of samples from playback (currently 2048 samples). To mitigate this, check for an underrun retval (`-EPIPE`) after calling `snd_pcm_writei()` and if applicable, recover by calling `snd_pcm_prepare()` and repeating the `snd_pcm_writei()` call to avoid dropping samples. Also implement an `alsa_pause()` function to pause and resume playback without a buffer underrun using `snd_pcm_pause()`. The call will be ineffective if unsupported by underlying hardware, in which case the buffer underrun handling above will come into play.
- Loading branch information