From d5b081152aecb947215f7b8aa091ca2031c94edc Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 27 Oct 2014 11:52:42 +0100 Subject: audio: add command/function to reload audio output Anticipated use: simple solution for dealing with audio APIs which request configuration changes via events. --- player/command.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'player/command.c') 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); -- cgit v1.2.3