summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-05 00:13:00 +0200
committerAlessandro Ghedini <alessandro@ghedini.me>2014-10-11 13:57:34 +0200
commit1b29964a3efc28e2eeb52ba83aa0e855c7aba703 (patch)
treee3551caeb18d707f2dae6d3e4c5df06322ca9378
parent180fed4bc48d644fd75d0c2ca89fd4a412710de9 (diff)
downloadmpv-1b29964a3efc28e2eeb52ba83aa0e855c7aba703.tar.bz2
mpv-1b29964a3efc28e2eeb52ba83aa0e855c7aba703.tar.xz
audio/out/push: limit fallback sleep time to reasonable limits
-rw-r--r--audio/out/push.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/audio/out/push.c b/audio/out/push.c
index 75b4db0568..dd3a02b79a 100644
--- a/audio/out/push.c
+++ b/audio/out/push.c
@@ -165,8 +165,10 @@ static void drain(struct ao *ao)
pthread_cond_wait(&p->wakeup_drain, &p->lock);
pthread_mutex_unlock(&p->lock);
- if (!ao->driver->drain)
- mp_sleep_us(get_delay(ao) * 1000000);
+ if (!ao->driver->drain) {
+ double time = get_delay(ao);
+ mp_sleep_us(MPMIN(time, ao->buffer / (double)ao->samplerate + 1) * 1e6);
+ }
reset(ao);
}