From a3bf75279e806084ee1235e6a5bb5b9fdd8c7095 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 11 Oct 2014 21:28:45 +0200 Subject: command: make volume/mute unavailable if audio is not initialized This does nothing good. This reverts a change made over a year ago - I don't remember why this was originally done this way. The main problem is that even if the volume option is set (something like "--volume=75"), the volume property will always return "100" until audio is initialized. If audio is uninitialized again, the volume property will remain frozen at its last value. --- player/command.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/player/command.c b/player/command.c index ba223bb870..da2e7de125 100644 --- a/player/command.c +++ b/player/command.c @@ -1236,6 +1236,8 @@ static int mp_property_volume(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; + if (!mixer_audio_initialized(mpctx->mixer)) + return M_PROPERTY_UNAVAILABLE; switch (action) { case M_PROPERTY_GET: mixer_getbothvolume(mpctx->mixer, arg); @@ -1258,13 +1260,9 @@ static int mp_property_volume(void *ctx, struct m_property *prop, return M_PROPERTY_OK; } case M_PROPERTY_SET: - if (!mixer_audio_initialized(mpctx->mixer)) - return M_PROPERTY_ERROR; mixer_setvolume(mpctx->mixer, *(float *) arg, *(float *) arg); return M_PROPERTY_OK; case M_PROPERTY_SWITCH: { - if (!mixer_audio_initialized(mpctx->mixer)) - return M_PROPERTY_ERROR; struct m_property_switch_arg *sarg = arg; mixer_addvolume(mpctx->mixer, sarg->inc); return M_PROPERTY_OK; @@ -1278,10 +1276,10 @@ static int mp_property_mute(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; + if (!mixer_audio_initialized(mpctx->mixer)) + return M_PROPERTY_ERROR; switch (action) { case M_PROPERTY_SET: - if (!mixer_audio_initialized(mpctx->mixer)) - return M_PROPERTY_ERROR; mixer_setmute(mpctx->mixer, *(int *) arg); return M_PROPERTY_OK; case M_PROPERTY_GET: -- cgit v1.2.3