From 8894a4b0d2b38781d9ab110a18e27fef99d956f1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 7 Sep 2013 20:03:13 +0200 Subject: command: make options writeable in idle mode Until now, options could be accessed as properties via "options/name", but the access was read-only. Change it so that write access is possible in --idle mode. (All options have to support setting options at that time, simply because of the way MPlayer designed per-file options. During playback, normal properties take care of changing things, including things backed by options.) This is work in progress. There are some issues: at least setting the "vf" and "af" options won't work for strange reasons. --- mpvcore/command.c | 8 ++++++++ mpvcore/mp_core.h | 1 + mpvcore/mplayer.c | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'mpvcore') diff --git a/mpvcore/command.c b/mpvcore/command.c index fa2bbf963c..3e217dd5d7 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -1652,6 +1652,14 @@ static int mp_property_options(m_option_t *prop, int action, void *arg, case M_PROPERTY_GET: m_option_copy(opt->opt, ka->arg, opt->data); return M_PROPERTY_OK; + case M_PROPERTY_SET: + if (!(mpctx->initialized_flags & INITIALIZED_PLAYBACK) && + !(opt->opt->flags & (M_OPT_PRE_PARSE | M_OPT_GLOBAL))) + { + m_option_copy(opt->opt, opt->data, ka->arg); + return M_PROPERTY_OK; + } + return M_PROPERTY_ERROR; case M_PROPERTY_GET_TYPE: *(struct m_option *)ka->arg = *opt->opt; return M_PROPERTY_OK; diff --git a/mpvcore/mp_core.h b/mpvcore/mp_core.h index 3bf2c8d6aa..6e601c88ba 100644 --- a/mpvcore/mp_core.h +++ b/mpvcore/mp_core.h @@ -31,6 +31,7 @@ #define INITIALIZED_AO 2 #define INITIALIZED_VOL 4 #define INITIALIZED_GETCH2 8 +#define INITIALIZED_PLAYBACK 16 #define INITIALIZED_STREAM 64 #define INITIALIZED_DEMUXER 512 #define INITIALIZED_ACODEC 1024 diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c index 2e3751a845..c6eff97338 100644 --- a/mpvcore/mplayer.c +++ b/mpvcore/mplayer.c @@ -546,6 +546,9 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask) ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE); mpctx->ao = NULL; } + + if (mask & INITIALIZED_PLAYBACK) + mpctx->initialized_flags &= ~INITIALIZED_PLAYBACK; } static MP_NORETURN void exit_player(struct MPContext *mpctx, @@ -4171,6 +4174,7 @@ static void play_current_file(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; + mpctx->initialized_flags |= INITIALIZED_PLAYBACK; mpctx->stop_play = 0; mpctx->filename = NULL; -- cgit v1.2.3