1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-20 22:02:59 +00:00

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.
This commit is contained in:
wm4 2014-10-11 21:28:45 +02:00
parent f2ef3e664b
commit a3bf75279e

View File

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