From 20988ee6076bac53015b6eaab753203ca7dd6a8c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 12 Oct 2013 18:28:02 +0200 Subject: 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. --- audio/mixer.c | 5 +++++ audio/mixer.h | 1 + 2 files changed, 6 insertions(+) (limited to 'audio') diff --git a/audio/mixer.c b/audio/mixer.c index 07ce229f73..f3e9d959aa 100644 --- a/audio/mixer.c +++ b/audio/mixer.c @@ -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) diff --git a/audio/mixer.h b/audio/mixer.h index 9fbb4bcdca..e2e574c22e 100644 --- a/audio/mixer.h +++ b/audio/mixer.h @@ -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); -- cgit v1.2.3