diff --git a/output.c b/output.c index cf69f2c..f03701e 100644 --- a/output.c +++ b/output.c @@ -827,7 +827,16 @@ #if ALSA snd_pcm_sframes_t delay; snd_pcm_delay(pcmp, &delay); - output.device_frames = delay; + if (delay >= 0) { + output.device_frames = delay; + } else { + LOG_WARN("snd_pcm_delay returns: %d", delay); + if (delay == -EPIPE) { + // EPIPE indicates underrun - attempt to recover + UNLOCK; + continue; + } + } #endif #if PORTAUDIO output.device_frames = (unsigned)((time_info->outputBufferDacTime - Pa_GetStreamTime(pa.stream)) * output.current_sample_rate);