client API: add events for video and audio reconfig

This commit is contained in:
wm4 2014-02-17 02:52:26 +01:00
parent b3b59b9a2d
commit 5fcf4b46f7
7 changed files with 34 additions and 1 deletions

View File

@ -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.

View File

@ -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;
/**

View File

@ -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);

View File

@ -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)

View File

@ -21,6 +21,8 @@
#include <stdbool.h>
#include "libmpv/client.h"
#include "common/common.h"
#include "options/options.h"
#include "sub/osd.h"

View File

@ -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);
}
}

View File

@ -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.