summaryrefslogtreecommitdiffstats
path: root/libao2/ao_alsa.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2008-12-10 02:47:38 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2008-12-10 02:54:01 +0200
commitf01f7f6259badb2725be49af914d8db52e025cf6 (patch)
tree0d9545588f4601bab9b3968e01073809cfc214b4 /libao2/ao_alsa.c
parent6fa90873ccc8006e479061afdd0edfbfdadf17ec (diff)
downloadmpv-f01f7f6259badb2725be49af914d8db52e025cf6.tar.bz2
mpv-f01f7f6259badb2725be49af914d8db52e025cf6.tar.xz
ao_alsa: Sanity check get_space() return values better
Sometimes after seek audio reset I see snd_pcm_status_get_avail() return huge values. get_space() already had a check againt the value being larger than the whole buffer; however since the unsigned value from the ALSA function had been cast to signed by that point it was interpreted as negative and the check didn't trigger. Use unsigned instead to make the check reliable and ensure the return value is sane.
Diffstat (limited to 'libao2/ao_alsa.c')
-rw-r--r--libao2/ao_alsa.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 81bcc2c8b3..fdaaac1551 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -878,10 +878,10 @@ static int get_space(void)
return 0;
}
- ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
- if (ret > ao_data.buffersize) // Buffer underrun?
- ret = ao_data.buffersize;
- return ret;
+ unsigned space = snd_pcm_status_get_avail(status) * bytes_per_sample;
+ if (space > ao_data.buffersize) // Buffer underrun?
+ space = ao_data.buffersize;
+ return space;
}
/* delay in seconds between first and last sample in buffer */