summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-10-12 18:28:02 +0200
committerwm4 <wm4@nowhere>2013-10-12 18:57:02 +0200
commit20988ee6076bac53015b6eaab753203ca7dd6a8c (patch)
treee8a7d8b08dca4fac7a860a072d1ffa18769f4186 /mpvcore
parent38874b2f2e3a5e0473bada789ef04af632e27ecb (diff)
downloadmpv-20988ee6076bac53015b6eaab753203ca7dd6a8c.tar.bz2
mpv-20988ee6076bac53015b6eaab753203ca7dd6a8c.tar.xz
command: don't allow changing volume if no audio initialized
Changing volume when audio is disabled was a feature request (github issue #215), and was introduced with commit 327a779. But trying to fix github issue #280 (volume is not correct in no-audio mode, and if audio is re-enabled, the volume set in no-audio mode isn't set), I concluded that it's not worth the trouble and the current implementation is questionable all around. (For example, you can't change the real volume in no-audio mode, even if the AO is open - this could happen with gapless audio.) It's hard to get right, and the current mixer code is already hilariously overcomplicated. (Virtually all of mixer.c is an amalgamation of various obscure corner cases.) So just remove this feature again. Note that "options/volume" and "options/mute" still can be used in idle mode to adjust the volume used next time, though these properties can't be used during playback and thus not in audio-only mode. Querying the volume still "works" in audio-only mode, though it can return bogus values.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index f16d171bf4..c9eb21dd0b 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -768,9 +768,13 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg,
mixer_getbothvolume(mpctx->mixer, arg);
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;
if (sarg->inc <= 0)
mixer_decvolume(mpctx->mixer);
@@ -788,6 +792,8 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg,
{
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: