summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-27 11:52:42 +0100
committerwm4 <wm4@nowhere>2014-10-27 11:52:42 +0100
commitd5b081152aecb947215f7b8aa091ca2031c94edc (patch)
treefff6d188ede259a9315489e89396e1b0d5c6b366 /player/command.c
parentac35e3b308a2469ef49b7094de8b571f054ac2f4 (diff)
downloadmpv-d5b081152aecb947215f7b8aa091ca2031c94edc.tar.bz2
mpv-d5b081152aecb947215f7b8aa091ca2031c94edc.tar.xz
audio: add command/function to reload audio output
Anticipated use: simple solution for dealing with audio APIs which request configuration changes via events.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 5cdd57110c..a4ef70082c 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1454,6 +1454,18 @@ static int get_device_entry(int item, int action, void *arg, void *ctx)
return m_property_read_sub(props, action, arg);
}
+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);
+}
+
static int mp_property_audio_devices(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -4233,6 +4245,10 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
}
break;
+ case MP_CMD_AO_RELOAD:
+ reload_audio_output(mpctx);
+ break;
+
case MP_CMD_AF:
return edit_filters_osd(mpctx, STREAM_AUDIO, cmd->args[0].v.s,
cmd->args[1].v.s, msg_osd);