1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00
mpv/video/out
wm4 e265c07547 vo: fix missed option updates under rare circumstances
Dear diary,

today I fixed a shitty bug that was all my fault because I made a
horrible mess. (Except it was a horrible mess before I even touched
this shit, but let's not blame others.)

Sometimes, updates to VO option that control video sizing (like panscan)
didn't update the screen correctly. They were delayed until the next
option change or so.

It turns out that if the option update happens at the "same" time as a
VOCTRL, update_opts() doesn't actually notify the vo_driver of the
change. This in turn happened because run_control() called
m_config_cache_update(). The latter function returns true if the options
changed since the last call, and update_opts() also calls it (on the
same config cache) for the same purpose. The update_opts() call, which
is triggered by a third mechanism, comes later, but the cache update
call will return false (as it should). Basically, given the config API,
you can't act differently on multiple update calls and expect it to
work. The skipped handling in update_opts() meant that the notification
required to apply the changed option wasn't run.

Fix this by simply calling update_opts() directly instead. Now there's
only 1 m_config_cache_update() call on this specific instance. Fix the
call in run_reconfig() too, so the previous sentence isn't a lie (but it
probably doesn't make a difference in practice due to certain details).

I'm not sure how I even ran into this sort-of race condition. The VOCTRL
that messed up the option update was VOCTRL_UPDATE_PLAYBACK_STATE, which
happens semi-regularly.

Why this config cache shit and all the other shit? Rediscovering this
crap wasn't pleasant. It's a bunch of hacks that became necessary when
the ancient MPlayer architecture made it hard to move the VO to a
separate thread.

All the VO code typically accesses vo->opts (whose fields all used to be
global variables in MPlayer). The frontend changes these on user input.
Putting locking around all the options would be a nightmare, and keeping
a copy of the options in the thread was much simpler. You need a way to
propagate option changes, notify the thread, and update the local copy
too. And the result of these thoughts was the config cache mechanism.

In this specific case, the relevant cache update call in update_opts()
triggers a VOCTRL_SET_PANSCAN to the VO driver, which isn't related to
its former function anymore. Instead, it causes the VO driver to update
the video sizing/placing options, which the generic VO code can't do.
(Mostly because the VO driver includes the windowing stuff and is
responsible for resizing etc. itself.)

VOCTRLs sent by the frontend are even worse. MPlayer had no real runtime
option change mechanism. Some options were vaguely duplicated by
properties, so you could effectively change those options at runtime.
Each of these options had its own VOCTRL, which still exist today, e.g.
VOCTRL_FULLSCREEN, or VOCTRL_ONTOP. I tried to make all options runtime
changeable, and to unify properties with options. But I couldn't be
bothered with updating all VO drivers to listen to option changes
directly, because that would be pretty tedious. So the property code is
still all there and sends the old VOCTRLs. But of course you need to
sync up the options, which is why the run_control() code did that.

(Unrelated: VO_EVENT_FULLSCREEN_STATE is the worst shithack of them all.
Currently, only the frontend can actually write to options (for awful
reasons), so if the fullscreen state changes due to outside interaction,
the VO driver can't update the corresponding option fields. So the VO
notifies the frontend with said VO_EVENT_, and the frontend then sends
VOCTRL_GET_FULLSCREEN, and updates the global copy of the option with
the value returned by that. I still like to think the situation is not
that bad considering the monstrous effort of converting single-threaded
code that had hundreds of options in global variables to multi-threaded
code with no global variables at all.)
2019-09-19 20:37:05 +02:00
..
cocoa cocoa: fix drawing on macOS 10.14 2018-11-13 21:14:29 +02:00
cocoa-cb cocoa-cb: remove an unused variable 2019-09-02 00:39:36 +03:00
d3d11 vo_d3d11/context: fix crash due to ctx->ra is null pointer access 2019-09-14 21:35:49 +10:00
gpu vo_gpu: remove vdpau/GLX backend 2019-09-19 20:37:05 +02:00
hwdec vo_gpu: hwdec_vaegl: silence confusing message during probing 2019-09-19 20:37:05 +02:00
opengl vo_gpu: remove vdpau/GLX backend 2019-09-19 20:37:05 +02:00
placebo video/out/gpu: Add a storable flag to ra_format 2019-07-08 00:59:28 +02:00
vulkan vo/gpu: vulkan: Pass the device name option through to libplacebo 2019-08-24 18:38:27 +02:00
win32 vo_gpu: win: remove exclusive-fullscreen detection hack 2017-12-20 14:53:41 +11:00
aspect.c aspect: add video margin options 2019-09-19 20:37:05 +02:00
aspect.h aspect: change license to LGPL 2017-06-17 17:08:51 +02:00
bitmap_packer.c bitmap_packer: remove some unused functions 2016-07-01 20:29:45 +02:00
bitmap_packer.h bitmap_packer: remove some unused functions 2016-07-01 20:29:45 +02:00
cocoa_cb_common.swift cocoa-cb: migrate to swift 5 with swift 4 fallback 2019-07-21 18:13:07 +03:00
cocoa_common.h osx: change license of OSX and cocoa files to LGPL 2017-06-24 16:29:22 +02:00
cocoa_common.m {mac,cocoa}: trim trailing null out of macosx_icon when loading it 2018-10-02 00:20:43 +03:00
d3d_shader_420p.h vo_direct3d: support NV12 with shaders 2015-03-02 19:09:18 +01:00
d3d_shader_yuv.hlsl vo_direct3d: support NV12 with shaders 2015-03-02 19:09:18 +01:00
dither.c Change GPL/LGPL dual-licensed files to LGPL 2016-01-19 18:36:34 +01:00
dither.h gl_video: improve dithering 2013-05-26 16:44:20 +02:00
dr_helper.c vo: move DR helper code to a separate source file 2018-04-29 02:21:32 +03:00
dr_helper.h vo: move DR helper code to a separate source file 2018-04-29 02:21:32 +03:00
drm_atomic.c drm: rename plane options to better, invariant, names 2018-12-01 15:42:20 +02:00
drm_atomic.h drm: rename plane options to better, invariant, names 2018-12-01 15:42:20 +02:00
drm_common.c drm_common: Support --drm-mode=<preferred|highest|N|WxH[@R]> 2019-05-04 14:17:11 +02:00
drm_common.h drm_common: Don't export functions only being used internally 2019-05-04 14:17:11 +02:00
drm_prime.c Add DRM_PRIME Format Handling and Display for RockChip MPP decoders 2017-10-23 21:07:24 +02:00
drm_prime.h Add DRM_PRIME Format Handling and Display for RockChip MPP decoders 2017-10-23 21:07:24 +02:00
filter_kernels.c vo_opengl: refactor scaler LUT weight packing/loading 2017-09-04 13:53:14 +02:00
filter_kernels.h vo_opengl: refactor scaler LUT weight packing/loading 2017-09-04 13:53:14 +02:00
libmpv.h vo_libmpv: support render performance data 2018-11-13 20:43:29 +02:00
vo_caca.c Add checks for HAVE_GPL to various GPL-only source files 2017-10-10 15:51:16 +02:00
vo_direct3d.c Add checks for HAVE_GPL to various GPL-only source files 2017-10-10 15:51:16 +02:00
vo_drm.c drm_common: Add proper help option to drm-mode 2019-05-04 14:17:11 +02:00
vo_gpu.c vo: use a struct for vsync feedback stuff 2018-12-06 10:30:25 +01:00
vo_image.c image_writer, vo_image: change license to LGPL 2017-06-18 15:45:24 +02:00
vo_lavc.c encode: get rid of the output packet queue 2018-05-03 01:08:44 +03:00
vo_libmpv.c vo_libmpv: fix null pointer dereference 2019-03-11 01:55:59 +02:00
vo_mediacodec_embed.c vo_mediacodec_embed: fix forgotten VO_CAP_NOREDRAW→VO_CAP_NORETAIN 2018-02-20 01:59:20 +02:00
vo_null.c vo.c, vo.h, vo_null.c: change license to LGPL 2017-05-10 15:06:20 +02:00
vo_rpi.c vo_gpu: add internal ability to skip osd/subs for rendering 2018-02-11 17:45:51 -08:00
vo_sdl.c vo_sdl: add support for screensaver VOCTRL's 2018-06-02 23:34:38 +03:00
vo_tct.c sws_utils: don't force callers to provide option struct 2018-01-18 00:59:07 -08:00
vo_vaapi.c vo: add warning message to vo_vaapi and vo_vdpau 2019-09-14 13:50:10 +02:00
vo_vdpau.c vo: add warning message to vo_vaapi and vo_vdpau 2019-09-14 13:50:10 +02:00
vo_x11.c vo_x11: fix return value in resize() error paths 2018-11-17 00:53:56 +01:00
vo_xv.c build: remove POSIX/sysv shared memory test 2017-12-02 23:19:13 +01:00
vo.c vo: fix missed option updates under rare circumstances 2019-09-19 20:37:05 +02:00
vo.h vo, vo_gpu, glx: correct GLX_OML_sync_control usage 2018-12-06 10:32:27 +01:00
w32_common.c w32_common: avoid unnecessary sprintfs 2019-05-10 20:47:05 +10:00
w32_common.h w32_common, w32_keyboard: change license to LGPL 2017-06-24 12:54:45 +02:00
wayland_common.c wayland: fix wl_proxy leak 2019-09-19 00:00:19 +03:00
wayland_common.h wayland_common: rename “shell” into “wm_base” 2019-02-17 23:44:34 +02:00
win_state.c win_state: silence a valgrind warning 2019-09-19 20:37:05 +02:00
win_state.h x11: pseudo HiDPI scaling 2017-01-19 16:31:54 +01:00
x11_common.c x11: fix cursor hiding initial state 2019-03-16 21:17:32 +01:00
x11_common.h x11: fix cursor hiding initial state 2019-03-16 21:17:32 +01:00