From 040c050f2d26ff6f2d5a625fdc6cbb19f3b65f5d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 4 May 2014 20:41:00 +0200 Subject: 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. --- audio/out/push.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'audio/out/push.c') diff --git a/audio/out/push.c b/audio/out/push.c index 400b93a0f4..bbb6878abf 100644 --- a/audio/out/push.c +++ b/audio/out/push.c @@ -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); -- cgit v1.2.3