mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
audio: fix UB when casting INFINITY to integer
Fixes busy wait, because in practice inf would be casted to 0.
Fixes: 174df99
This commit is contained in:
parent
39cab760b3
commit
a6fb9321ea
@ -698,12 +698,12 @@ static MP_THREAD_VOID playthread(void *arg)
|
||||
|
||||
// Wait until the device wants us to write more data to it.
|
||||
// Fallback to guessing.
|
||||
double timeout = INFINITY;
|
||||
int64_t timeout = INT64_MAX;
|
||||
if (p->streaming && !retry && (!p->paused || ao->stream_silence)) {
|
||||
// Wake up again if half of the audio buffer has been played.
|
||||
// Since audio could play at a faster or slower pace, wake up twice
|
||||
// as often as ideally needed.
|
||||
timeout = ao->device_buffer / (double)ao->samplerate * 0.25;
|
||||
timeout = MP_TIME_S_TO_NS(ao->device_buffer / (double)ao->samplerate * 0.25);
|
||||
}
|
||||
|
||||
mp_mutex_unlock(&p->lock);
|
||||
@ -715,7 +715,7 @@ static MP_THREAD_VOID playthread(void *arg)
|
||||
}
|
||||
if (!p->need_wakeup && !retry) {
|
||||
MP_STATS(ao, "start audio wait");
|
||||
mp_cond_timedwait(&p->pt_wakeup, &p->pt_lock, MP_TIME_S_TO_NS(timeout));
|
||||
mp_cond_timedwait(&p->pt_wakeup, &p->pt_lock, timeout);
|
||||
MP_STATS(ao, "end audio wait");
|
||||
}
|
||||
p->need_wakeup = false;
|
||||
|
Loading…
Reference in New Issue
Block a user