summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-11 21:28:45 +0200
committerwm4 <wm4@nowhere>2014-10-11 21:35:08 +0200
commita3bf75279e806084ee1235e6a5bb5b9fdd8c7095 (patch)
tree976a87304dd5cd2d394a7ceb962e92074be3d5e1
parentf2ef3e664b57c9db330ff552d839e3453529874d (diff)
downloadmpv-a3bf75279e806084ee1235e6a5bb5b9fdd8c7095.tar.bz2
mpv-a3bf75279e806084ee1235e6a5bb5b9fdd8c7095.tar.xz
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.
-rw-r--r--player/command.c10
1 files 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: