summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-02-01 16:41:43 -0600
committerDudemanguy <random342@airmail.cc>2024-02-05 17:23:47 +0000
commit531868fe0d2a35fbbff78d9a9ff8f96df73e69fd (patch)
tree27917d2004335adcb17754829cc2870e2074f506
parent7616190aa4c41c738c53d11d4ef37e70551c39cc (diff)
downloadmpv-531868fe0d2a35fbbff78d9a9ff8f96df73e69fd.tar.bz2
mpv-531868fe0d2a35fbbff78d9a9ff8f96df73e69fd.tar.xz
player: ensure runtime updates of certain rendering options
When adding things like brightness or gamma, the video obviously needs a redraw if paused. This happened to work in the normal case because the OSD notification triggered a redraw, but if you use no-osd the picture won't change. Fix this by adding another option flag, UPDATE_VIDEO, and simply signalling we want a redraw. This gets handled along with the normal osd redrawing check in the playloop so something like "no-osd add gamma 1" actually works.
-rw-r--r--options/m_option.h3
-rw-r--r--player/command.c7
-rw-r--r--video/csputils.c1
-rw-r--r--video/out/gpu/video.c1
-rw-r--r--video/out/vo.c10
-rw-r--r--video/out/vo.h1
6 files changed, 22 insertions, 1 deletions
diff --git a/options/m_option.h b/options/m_option.h
index e62fa0fc26..d818a367b7 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -442,7 +442,8 @@ char *format_file_size(int64_t size);
#define UPDATE_DVB_PROG (1 << 21) // some --dvbin-...
#define UPDATE_SUB_HARD (1 << 22) // subtitle opts. that need full reinit
#define UPDATE_SUB_EXTS (1 << 23) // update internal list of sub exts
-#define UPDATE_OPT_LAST (1 << 23)
+#define UPDATE_VIDEO (1 << 24) // force redraw if needed
+#define UPDATE_OPT_LAST (1 << 24)
// All bits between _FIRST and _LAST (inclusive)
#define UPDATE_OPTS_MASK \
diff --git a/player/command.c b/player/command.c
index f84806ae52..ccde8647c3 100644
--- a/player/command.c
+++ b/player/command.c
@@ -7106,6 +7106,13 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
if (flags & UPDATE_LAVFI_COMPLEX)
update_lavfi_complex(mpctx);
+ if (flags & UPDATE_VIDEO) {
+ if (mpctx->video_out) {
+ vo_set_want_redraw(mpctx->video_out);
+ mp_wakeup_core(mpctx);
+ }
+ }
+
if (opt_ptr == &opts->vo->android_surface_size) {
if (mpctx->video_out)
vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL);
diff --git a/video/csputils.c b/video/csputils.c
index 6a55ddb38e..0587c57f4e 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -476,6 +476,7 @@ const struct m_sub_options mp_csp_equalizer_conf = {
{0}
},
.size = sizeof(struct mp_csp_equalizer_opts),
+ .change_flags = UPDATE_VIDEO,
};
// Copy settings from eq into params.
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index fcde3cd5c9..e52b7c91b2 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -483,6 +483,7 @@ const struct m_sub_options gl_video_conf = {
},
.size = sizeof(struct gl_video_opts),
.defaults = &gl_video_opts_def,
+ .change_flags = UPDATE_VIDEO,
};
static void uninit_rendering(struct gl_video *p);
diff --git a/video/out/vo.c b/video/out/vo.c
index 1a385f8285..ce93c66810 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -1171,6 +1171,16 @@ void vo_redraw(struct vo *vo)
mp_mutex_unlock(&in->lock);
}
+// Same as vo_redraw but the redraw is delayed until it
+// is detected in the playloop.
+void vo_set_want_redraw(struct vo *vo)
+{
+ struct vo_internal *in = vo->in;
+ mp_mutex_lock(&in->lock);
+ in->want_redraw = true;
+ mp_mutex_unlock(&in->lock);
+}
+
bool vo_want_redraw(struct vo *vo)
{
struct vo_internal *in = vo->in;
diff --git a/video/out/vo.h b/video/out/vo.h
index 895d6039fe..2d521d8a69 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -512,6 +512,7 @@ void vo_wait_frame(struct vo *vo);
bool vo_still_displaying(struct vo *vo);
bool vo_has_frame(struct vo *vo);
void vo_redraw(struct vo *vo);
+void vo_set_want_redraw(struct vo *vo);
bool vo_want_redraw(struct vo *vo);
void vo_seek_reset(struct vo *vo);
void vo_destroy(struct vo *vo);