From d2bdb72b69536370c3046107fc593896e74803c3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 Aug 2017 15:50:33 +0200 Subject: options: add a thread-safe way to notify option updates So far, we had a thread-safe way to read options, but no option update notification mechanism. Everything was funneled though the main thread's central mp_option_change_callback() function. For example, if the panscan options were changed, the function called vo_control() with VOCTRL_SET_PANSCAN to manually notify the VO thread of updates. This worked, but's pretty inconvenient. Most of these problems come from the fact that MPlayer was written as a single-threaded program. This commit works towards a more flexible mechanism. It adds an update callback to m_config_cache (the thing that is already used for thread-safe access of global options). This alone would still be rather inconvenient, at least in context of VOs. Add another mechanism on top of it that uses mp_dispatch_queue, and takes care of some annoying synchronization issues. We extend mp_dispatch_queue itself to make this easier and slightly more efficient. As a first application, use this to reimplement certain VO scaling and renderer options. The update_opts() function translates these to the "old" VOCTRLs, though. An annoyingly subtle issue is that m_config_cache's destructor now releases pending notifications, and must be released before the associated dispatch queue. Otherwise, it could happen that option updates during e.g. VO destruction queue or run stale entries, which is not expected. Rather untested. The singly-linked list code in dispatch.c is probably buggy, and I bet some aspects about synchronization are not entirely sane. --- player/command.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index 51b025cad4..80c0c970fa 100644 --- a/player/command.c +++ b/player/command.c @@ -5854,14 +5854,6 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) if (flags & UPDATE_TERM) mp_update_logging(mpctx, false); - if (mpctx->video_out) { - if (flags & UPDATE_VIDEOPOS) - vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL); - - if (flags & UPDATE_RENDERER) - vo_control(mpctx->video_out, VOCTRL_UPDATE_RENDER_OPTS, NULL); - } - if (flags & UPDATE_OSD) { osd_changed(mpctx->osd); for (int n = 0; n < NUM_PTRACKS; n++) { -- cgit v1.2.3