summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/lua.rst6
-rw-r--r--libmpv/client.h16
-rw-r--r--player/audio.c3
-rw-r--r--player/client.c2
-rw-r--r--player/core.h2
-rw-r--r--player/playloop.c2
-rw-r--r--player/video.c4
7 files changed, 34 insertions, 1 deletions
diff --git a/DOCS/man/en/lua.rst b/DOCS/man/en/lua.rst
index 89abcb00b5..25f1a81f96 100644
--- a/DOCS/man/en/lua.rst
+++ b/DOCS/man/en/lua.rst
@@ -391,3 +391,9 @@ List of events
``client-message``
Undocumented (used internally).
+
+``video-reconfig``
+ Happens on video output or filter reconfig.
+
+``audio-reconfig``
+ Happens on audio output or filter reconfig.
diff --git a/libmpv/client.h b/libmpv/client.h
index b59a4c3249..7bc613b15e 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -622,6 +622,22 @@ typedef enum mpv_event_id {
* the seconand argument as strings.
*/
MPV_EVENT_CLIENT_MESSAGE = 16,
+ /**
+ * Happens after video changed in some way. This can happen on resolution
+ * changes, pixel format changes, or video filter changes. The event is
+ * sent after the video filters and the VO are reconfigured. Applications
+ * embedding a mpv window should listen to this event in order to resize
+ * the window if needed.
+ * Note that this event can happen sporadically, and you should check
+ * yourself whether the video parameters really changed before doing
+ * something expensive.
+ */
+ MPV_EVENT_VIDEO_RECONFIG = 17,
+ /**
+ * Similar to MPV_EVENT_VIDEO_RECONFIG. This is relatively uninteresting,
+ * because there is no such thing as audio output embedding.
+ */
+ MPV_EVENT_AUDIO_RECONFIG = 18,
} mpv_event_id;
/**
diff --git a/player/audio.c b/player/audio.c
index 39e1eddabd..ed4d0f5f2a 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -39,6 +39,7 @@
#include "video/decode/dec_video.h"
#include "core.h"
+#include "command.h"
static int build_afilter_chain(struct MPContext *mpctx)
{
@@ -111,6 +112,8 @@ void reinit_audio_chain(struct MPContext *mpctx)
goto no_audio;
}
+ mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
+
if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) {
mpctx->initialized_flags |= INITIALIZED_ACODEC;
assert(!mpctx->d_audio);
diff --git a/player/client.c b/player/client.c
index 79f8f91324..f63611f79c 100644
--- a/player/client.c
+++ b/player/client.c
@@ -842,6 +842,8 @@ static const char *event_table[] = {
[MPV_EVENT_TICK] = "tick",
[MPV_EVENT_SCRIPT_INPUT_DISPATCH] = "script-input-dispatch",
[MPV_EVENT_CLIENT_MESSAGE] = "client-message",
+ [MPV_EVENT_VIDEO_RECONFIG] = "video-reconfig",
+ [MPV_EVENT_AUDIO_RECONFIG] = "audio-reconfig",
};
const char *mpv_event_name(mpv_event_id event)
diff --git a/player/core.h b/player/core.h
index 12f248dcc2..9048685827 100644
--- a/player/core.h
+++ b/player/core.h
@@ -21,6 +21,8 @@
#include <stdbool.h>
+#include "libmpv/client.h"
+
#include "common/common.h"
#include "options/options.h"
#include "sub/osd.h"
diff --git a/player/playloop.c b/player/playloop.c
index 57d5281240..261deaf217 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -51,7 +51,6 @@
#include "core.h"
#include "screenshot.h"
#include "command.h"
-#include "libmpv/client.h"
#define WAKEUP_PERIOD 0.5
@@ -893,6 +892,7 @@ void handle_force_window(struct MPContext *mpctx, bool reconfig)
};
vo_reconfig(vo, &p, 0);
redraw_osd(mpctx);
+ mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
}
}
diff --git a/player/video.c b/player/video.c
index 9ca5e9e697..348954c855 100644
--- a/player/video.c
+++ b/player/video.c
@@ -72,6 +72,10 @@ static void reconfig_video(struct MPContext *mpctx,
set_allowed_vo_formats(d_video->vfilter, mpctx->video_out);
+ // The event should happen _after_ filter and VO reconfig. Since we don't
+ // have any fine grained locking, this is just as good.
+ mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
+
if (video_reconfig_filters(d_video, params) < 0) {
// Most video filters don't work with hardware decoding, so this
// might be the reason filter reconfig failed.