diff options
author | wm4 <wm4@nowhere> | 2016-09-16 14:23:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-16 14:37:48 +0200 |
commit | b8ade7c99b830ee9870040bcfc1f2c3d3a64d172 (patch) | |
tree | 48df8031d90be4e6e1f9c9c4045a72e21c33862c /player/command.c | |
parent | f845f64c2abe4361084b4bc07f5f1ea5dd43ec9f (diff) | |
download | mpv-b8ade7c99b830ee9870040bcfc1f2c3d3a64d172.tar.bz2 mpv-b8ade7c99b830ee9870040bcfc1f2c3d3a64d172.tar.xz |
player, ao, vo: don't call mp_input_wakeup() directly
Currently, calling mp_input_wakeup() will wake up the core thread (also
called the playloop). This seems odd, but currently the core indeed
calls mp_input_wait() when it has nothing more to do. It's done this way
because MPlayer used input_ctx as central "mainloop".
This is probably going to change. Remove direct calls to this function,
and replace it with mp_wakeup_core() calls. ao and vo are changed to use
opaque callbacks and not use input_ctx for this purpose. Other code
already uses opaque callbacks, or has legitimate reasons to use
input_ctx directly (such as sending actual user input).
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/player/command.c b/player/command.c index 1b7f9eb088..bc103d0c6b 100644 --- a/player/command.c +++ b/player/command.c @@ -190,7 +190,7 @@ void mp_hook_run(struct MPContext *mpctx, char *client, char *type) next->active = true; if (!send_hook_msg(mpctx, next, "hook_run")) { hook_remove(mpctx, index); - mp_input_wakeup(mpctx->input); // repeat next iteration to finish + mp_wakeup_core(mpctx); // repeat next iteration to finish } } @@ -1742,14 +1742,24 @@ static void reload_audio_output(struct MPContext *mpctx) ao_request_reload(mpctx->ao); } +static void create_hotplug(struct MPContext *mpctx) +{ + struct command_ctx *cmd = mpctx->command_ctx; + + if (!cmd->hotplug) { + cmd->hotplug = ao_hotplug_create(mpctx->global, mp_wakeup_core_cb, + mpctx); + } +} + static int mp_property_audio_device(void *ctx, struct m_property *prop, int action, void *arg) { struct MPContext *mpctx = ctx; struct command_ctx *cmd = mpctx->command_ctx; if (action == M_PROPERTY_PRINT) { - if (!cmd->hotplug) - cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input); + create_hotplug(mpctx); + struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug); for (int n = 0; n < list->num_devices; n++) { struct ao_device_desc *dev = &list->devices[n]; @@ -1770,8 +1780,7 @@ static int mp_property_audio_devices(void *ctx, struct m_property *prop, { struct MPContext *mpctx = ctx; struct command_ctx *cmd = mpctx->command_ctx; - if (!cmd->hotplug) - cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input); + create_hotplug(mpctx); struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug); return m_property_read_list(action, arg, list->num_devices, @@ -1790,8 +1799,7 @@ static int mp_property_ao_detected_device(void *ctx,struct m_property *prop, { struct MPContext *mpctx = ctx; struct command_ctx *cmd = mpctx->command_ctx; - if (!cmd->hotplug) - cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input); + create_hotplug(mpctx); const char *d = ao_hotplug_get_detected_device(cmd->hotplug); return m_property_strdup_ro(action, arg, d); |