mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 23:21:54 +00:00
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.
This commit is contained in:
parent
38874b2f2e
commit
20988ee607
@ -59,6 +59,11 @@ struct mixer *mixer_init(void *talloc_ctx, struct MPOpts *opts)
|
||||
return mixer;
|
||||
}
|
||||
|
||||
bool mixer_audio_initialized(struct mixer *mixer)
|
||||
{
|
||||
return !!mixer->ao;
|
||||
}
|
||||
|
||||
static void checkvolume(struct mixer *mixer)
|
||||
{
|
||||
if (!mixer->ao)
|
||||
|
@ -36,6 +36,7 @@ struct mixer;
|
||||
struct mixer *mixer_init(void *talloc_ctx, struct MPOpts *opts);
|
||||
void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af);
|
||||
void mixer_uninit_audio(struct mixer *mixer);
|
||||
bool mixer_audio_initialized(struct mixer *mixer);
|
||||
void mixer_getvolume(struct mixer *mixer, float *l, float *r);
|
||||
void mixer_setvolume(struct mixer *mixer, float l, float r);
|
||||
void mixer_incvolume(struct mixer *mixer);
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user