mirror of https://github.com/mpv-player/mpv
audio: fix the exact value that is used for the wait time
The comment says that it wakes up the main thread if 50% has been played, but in reality the value was 0.74/2 => 37.5%. Correct this. This probably changes little, because it's a very fuzzy heuristic in the first place. Also move down the min_wait calculation to where it's actually used.
This commit is contained in:
parent
fb2e8387d4
commit
040c050f2d
|
@ -238,8 +238,6 @@ static void *playthread(void *arg)
|
|||
}
|
||||
double timeout = 2.0;
|
||||
if (p->playing) {
|
||||
double min_wait = ao->device_buffer / (double)ao->samplerate;
|
||||
min_wait *= 0.75;
|
||||
int r = ao_play_data(ao);
|
||||
// The device buffers are not necessarily full, but writing to the
|
||||
// AO buffer will wake up this thread anyway.
|
||||
|
@ -255,12 +253,13 @@ static void *playthread(void *arg)
|
|||
timeout = 0;
|
||||
}
|
||||
// Half of the buffer played -> wakeup playback thread to get more.
|
||||
double min_wait = ao->device_buffer / (double)ao->samplerate;
|
||||
if (timeout <= min_wait / 2 + 0.001)
|
||||
mp_input_wakeup(ao->input_ctx);
|
||||
// Avoid wasting CPU - this assumes ao_play_data() usually fills the
|
||||
// audio buffer as far as possible, so even if the device buffer
|
||||
// is not full, we can only wait for the core.
|
||||
timeout = MPMAX(timeout, min_wait);
|
||||
timeout = MPMAX(timeout, min_wait * 0.75);
|
||||
}
|
||||
pthread_mutex_unlock(&p->lock);
|
||||
pthread_mutex_lock(&p->wakeup_lock);
|
||||
|
|
Loading…
Reference in New Issue