diff options
author | wm4 <wm4@nowhere> | 2014-11-09 09:58:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-09 09:58:44 +0100 |
commit | b021d038c2217903e511ca3673d5f2f1b996c4d4 (patch) | |
tree | adc8258d5f8d18f11aa85f72fb6bc34ff62fb33f /player | |
parent | 7ee4e533693ee02e660ae0efb2e0e94db8c8c5af (diff) | |
download | mpv-b021d038c2217903e511ca3673d5f2f1b996c4d4.tar.bz2 mpv-b021d038c2217903e511ca3673d5f2f1b996c4d4.tar.xz |
audio/out: make ao_request_reload() idempotent
This is what you would expect. Before this commit, each
ao_request_reload() call would just queue a reload command, and then
recreate the AO for the number of times the function was called.
Instead of sending a command, introduce some sort of event retrieval
mechanism. At least for the reload case, use atomics, because we're too
lazy to setup an extra mutex.
Diffstat (limited to 'player')
-rw-r--r-- | player/audio.c | 5 | ||||
-rw-r--r-- | player/command.c | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/player/audio.c b/player/audio.c index 8df6053da1..fb3f571cdf 100644 --- a/player/audio.c +++ b/player/audio.c @@ -434,6 +434,11 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts) struct MPOpts *opts = mpctx->opts; struct dec_audio *d_audio = mpctx->d_audio; + if (mpctx->ao && ao_query_and_reset_events(mpctx->ao, AO_EVENT_RELOAD)) { + ao_reset(mpctx->ao); + uninit_audio_out(mpctx); + } + if (!d_audio) return; diff --git a/player/command.c b/player/command.c index 7df0c8a6c3..1968e6d5e5 100644 --- a/player/command.c +++ b/player/command.c @@ -1462,12 +1462,7 @@ static void reload_audio_output(struct MPContext *mpctx) { if (!mpctx->ao) return; - ao_reset(mpctx->ao); - uninit_audio_out(mpctx); - // This normally recreates the AO, although there are situations when AO - // creation is delayed; for example if there are no audio packets around, - // and the audio format is yet unknown. - reinit_audio_chain(mpctx); + ao_request_reload(mpctx->ao); } static int mp_property_audio_device(void *ctx, struct m_property *prop, |