diff options
author | wm4 <wm4@nowhere> | 2014-05-04 20:41:00 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-04 20:41:00 +0200 |
commit | 040c050f2d26ff6f2d5a625fdc6cbb19f3b65f5d (patch) | |
tree | a456a27ae3d6c873fa8ab1c7d4369a8abd29c03c | |
parent | fb2e8387d46346ca0079ba794931078134e89e3e (diff) | |
download | mpv-040c050f2d26ff6f2d5a625fdc6cbb19f3b65f5d.tar.bz2 mpv-040c050f2d26ff6f2d5a625fdc6cbb19f3b65f5d.tar.xz |
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.
-rw-r--r-- | audio/out/push.c | 5 |
1 files changed, 2 insertions, 3 deletions
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); |