summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-13 20:06:33 +0200
committerwm4 <wm4@nowhere>2014-07-13 20:06:33 +0200
commitfb54a1436aced8462d63c1cdbb4972c05829e26f (patch)
tree686a62c43ea7833e286c1d6d4bf1630e018c897f
parentb505cab59742dd47125153e63c690bf6ef591f61 (diff)
downloadmpv-fb54a1436aced8462d63c1cdbb4972c05829e26f.tar.bz2
mpv-fb54a1436aced8462d63c1cdbb4972c05829e26f.tar.xz
audio: don't wait for draining if paused
Logic for this was missing from pull.c. For push.c it was missing if the driver didn't support it. But even if the driver supported it (such as with ao_alsa), strange behavior was observed by users. See issue #933. Always check explicitly whether the AO is in paused mode, and if so, don't drain. Possibly fixes #933. CC: @mpv-player/stable
-rw-r--r--audio/out/ao.c14
-rw-r--r--audio/out/internal.h1
-rw-r--r--audio/out/pull.c9
-rw-r--r--audio/out/push.c7
4 files changed, 16 insertions, 15 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 977b8eb69a..8e1ceb4bf1 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -31,7 +31,6 @@
#include "options/options.h"
#include "options/m_config.h"
-#include "osdep/timer.h"
#include "common/msg.h"
#include "common/common.h"
#include "common/global.h"
@@ -313,22 +312,11 @@ void ao_resume(struct ao *ao)
ao->api->resume(ao);
}
-// Be careful with locking
-void ao_wait_drain(struct ao *ao)
-{
- // This is probably not entirely accurate, but good enough.
- mp_sleep_us(ao_get_delay(ao) * 1000000);
- ao_reset(ao);
-}
-
// Block until the current audio buffer has played completely.
void ao_drain(struct ao *ao)
{
- if (ao->api->drain) {
+ if (ao->api->drain)
ao->api->drain(ao);
- } else {
- ao_wait_drain(ao);
- }
}
bool ao_eof_reached(struct ao *ao)
diff --git a/audio/out/internal.h b/audio/out/internal.h
index 3d586f3848..75f5798bff 100644
--- a/audio/out/internal.h
+++ b/audio/out/internal.h
@@ -158,7 +158,6 @@ struct ao_driver {
// These functions can be called by AOs.
int ao_play_silence(struct ao *ao, int samples);
-void ao_wait_drain(struct ao *ao);
int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_us);
struct pollfd;
int ao_wait_poll(struct ao *ao, struct pollfd *fds, int num_fds,
diff --git a/audio/out/pull.c b/audio/out/pull.c
index 7902c9afb6..eb77be81a2 100644
--- a/audio/out/pull.c
+++ b/audio/out/pull.c
@@ -193,6 +193,14 @@ static void resume(struct ao *ao)
ao->driver->resume(ao);
}
+static void drain(struct ao *ao)
+{
+ struct ao_pull_state *p = ao->api_priv;
+ if (atomic_load(&p->state) == AO_STATE_PLAY)
+ mp_sleep_us(get_delay(ao) * 1000000);
+ reset(ao);
+}
+
static void uninit(struct ao *ao)
{
ao->driver->uninit(ao);
@@ -212,6 +220,7 @@ const struct ao_driver ao_api_pull = {
.init = init,
.control = control,
.uninit = uninit,
+ .drain = drain,
.reset = reset,
.get_space = get_space,
.play = play,
diff --git a/audio/out/push.c b/audio/out/push.c
index 6b04586b43..0ecba19da7 100644
--- a/audio/out/push.c
+++ b/audio/out/push.c
@@ -146,6 +146,10 @@ static void drain(struct ao *ao)
struct ao_push_state *p = ao->api_priv;
pthread_mutex_lock(&p->lock);
+ if (p->paused) {
+ pthread_mutex_unlock(&p->lock);
+ return;
+ }
p->final_chunk = true;
p->drain = true;
wakeup_playthread(ao);
@@ -154,7 +158,8 @@ static void drain(struct ao *ao)
pthread_mutex_unlock(&p->lock);
if (!ao->driver->drain)
- ao_wait_drain(ao);
+ mp_sleep_us(get_delay(ao) * 1000000);
+ reset(ao);
}
static int unlocked_get_space(struct ao *ao)