mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 08:12:17 +00:00
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.
This commit is contained in:
parent
6fa90873cc
commit
f01f7f6259
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user