summaryrefslogtreecommitdiffstats
path: root/audio/mixer.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-19 14:32:09 +0200
committerwm4 <wm4@nowhere>2013-09-19 14:32:09 +0200
commit38b2c97fd6b59b923ad309c19c457cbc0210da17 (patch)
tree9a0512b19ab0c0ce7ca3470512c0b648ee2afc57 /audio/mixer.h
parent4ba52a9e821486d9d9b076a5187583af144b8cec (diff)
downloadmpv-38b2c97fd6b59b923ad309c19c457cbc0210da17.tar.bz2
mpv-38b2c97fd6b59b923ad309c19c457cbc0210da17.tar.xz
mixer: refactor, fix some aspects of --volume handling
Refactor how mixer.c does volume/mute restoration and initialization. Move to handling of --volume and --mute to mixer.c. Simplify the implementation of these and hopefully fix bugs/strange behavior related to using them as file-local options (this uses a somewhat dirty trick: the option values are reverted to "auto" after initialization). Put most code related to initialization and volume restoring in probe_softvol() and restore_volume(). Having this code all in one place is less confusing. Instead of trying to detect whether to use softvol at runtime, detect it at initialization time using AOCONTROL_GET_VOLUME (same with mute, AOCONTROL_GET_MUTE). This implies we expect SET_VOLUME/SET_MUTE to work if the GET variants work. Hopefully this is always the case. This is also preparation for being able to change volume/mute settings if audio is disabled, and for allowing restoring value with playback resume.
Diffstat (limited to 'audio/mixer.h')
-rw-r--r--audio/mixer.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/audio/mixer.h b/audio/mixer.h
index b22bba0310..6761be5da4 100644
--- a/audio/mixer.h
+++ b/audio/mixer.h
@@ -21,6 +21,7 @@
#include <stdbool.h>
+// Values of MPOpts.softvol
enum {
SOFTVOL_NO = 0,
SOFTVOL_YES = 1,
@@ -31,19 +32,22 @@ typedef struct mixer {
struct MPOpts *opts;
struct ao *ao;
struct af_stream *af;
- int softvol;
+ // Static, dependent on ao/softvol settings
+ bool softvol; // use AO (true) or af_volume (false)
+ bool emulate_mute; // if true, emulate mute with volume=0
+ // Last known values (possibly out of sync with reality)
+ float vol_l, vol_r;
bool muted;
+ // Used to decide whether we should unmute on uninit
bool muted_by_us;
- bool muted_using_volume;
- float vol_l, vol_r;
/* Contains ao driver name or "softvol" if volume is not persistent
* and needs to be restored after the driver is reinitialized. */
- const char *restore_volume;
+ const char *driver;
+ // Other stuff
float balance;
- bool user_set_mute;
- bool user_set_volume;
} mixer_t;
+void mixer_init(struct mixer *mixer, struct MPOpts *opts);
void mixer_reinit_audio(struct mixer *mixer, struct ao *ao, struct af_stream *af);
void mixer_uninit_audio(struct mixer *mixer);
void mixer_getvolume(mixer_t *mixer, float *l, float *r);