From f3f194293a217aac189e8c5dff21473c9148ddcb Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Sun, 28 Feb 2016 17:01:13 +0100 Subject: [PATCH] Fix underflow detection for alsa The old method always returned _RUNNING on some machines. This new method seems to produce the expected behaviour. Note: -32 is probably -EPIPE, but the appropriate constant was not available at this time. --- src/alsa/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alsa/mod.rs b/src/alsa/mod.rs index f39e31f..80ba236 100644 --- a/src/alsa/mod.rs +++ b/src/alsa/mod.rs @@ -317,8 +317,8 @@ impl Voice { pub fn underflowed(&self) -> bool { let channel = self.channel.lock().expect("channel underflow"); - let state = unsafe { alsa::snd_pcm_state(*channel) }; - state == alsa::SND_PCM_STATE_XRUN + let available = unsafe { alsa::snd_pcm_avail(*channel) }; + available == -32 } }