diff options
Diffstat (limited to 'mpvcore/command.c')
-rw-r--r-- | mpvcore/command.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c index dedac9dc10..a2de363b3d 100644 --- a/mpvcore/command.c +++ b/mpvcore/command.c @@ -762,23 +762,19 @@ static int mp_property_clock(m_option_t *prop, int action, void *arg, static int mp_property_volume(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - - if (!mpctx->sh_audio) - return M_PROPERTY_UNAVAILABLE; - switch (action) { case M_PROPERTY_GET: - mixer_getbothvolume(&mpctx->mixer, arg); + mixer_getbothvolume(mpctx->mixer, arg); return M_PROPERTY_OK; case M_PROPERTY_SET: - mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); + mixer_setvolume(mpctx->mixer, *(float *) arg, *(float *) arg); return M_PROPERTY_OK; case M_PROPERTY_SWITCH: { struct m_property_switch_arg *sarg = arg; if (sarg->inc <= 0) - mixer_decvolume(&mpctx->mixer); + mixer_decvolume(mpctx->mixer); else - mixer_incvolume(&mpctx->mixer); + mixer_incvolume(mpctx->mixer); return M_PROPERTY_OK; } } @@ -789,21 +785,32 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, static int mp_property_mute(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - - if (!mpctx->sh_audio) - return M_PROPERTY_UNAVAILABLE; - switch (action) { case M_PROPERTY_SET: - mixer_setmute(&mpctx->mixer, *(int *) arg); + mixer_setmute(mpctx->mixer, *(int *) arg); return M_PROPERTY_OK; case M_PROPERTY_GET: - *(int *)arg = mixer_getmute(&mpctx->mixer); + *(int *)arg = mixer_getmute(mpctx->mixer); return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_volrestore(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + switch (action) { + case M_PROPERTY_GET: { + char *s = mixer_get_volume_restore_data(mpctx->mixer); + *(char **)arg = s; + return s ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE; + } + case M_PROPERTY_SET: + return M_PROPERTY_NOT_IMPLEMENTED; + } + return mp_property_generic_option(prop, action, arg, mpctx); +} + /// Audio delay (RW) static int mp_property_audio_delay(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -899,11 +906,11 @@ static int mp_property_balance(m_option_t *prop, int action, void *arg, switch (action) { case M_PROPERTY_GET: - mixer_getbalance(&mpctx->mixer, arg); + mixer_getbalance(mpctx->mixer, arg); return M_PROPERTY_OK; case M_PROPERTY_PRINT: { char **str = arg; - mixer_getbalance(&mpctx->mixer, &bal); + mixer_getbalance(mpctx->mixer, &bal); if (bal == 0.f) *str = talloc_strdup(NULL, "center"); else if (bal == -1.f) @@ -918,7 +925,7 @@ static int mp_property_balance(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; } case M_PROPERTY_SET: - mixer_setbalance(&mpctx->mixer, *(float *)arg); + mixer_setbalance(mpctx->mixer, *(float *)arg); return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; @@ -1806,6 +1813,7 @@ static const m_option_t mp_properties[] = { M_OPTION_PROPERTY_CUSTOM("aid", mp_property_audio), { "balance", mp_property_balance, CONF_TYPE_FLOAT, M_OPT_RANGE, -1, 1, NULL }, + M_OPTION_PROPERTY_CUSTOM("volume-restore-data", mp_property_volrestore), // Video M_OPTION_PROPERTY_CUSTOM("fullscreen", mp_property_fullscreen), |