summaryrefslogtreecommitdiffstats
path: root/audio/mixer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-09 23:25:31 +0100
committerwm4 <wm4@nowhere>2013-11-09 23:32:58 +0100
commitd6abfcd5784b033803d325b4dbb17836fdf7031e (patch)
treecd59b3eaffeaa9099dd23fabf576428ac4437941 /audio/mixer.c
parent0f8210753547f3de559e5b762a65c0bcc68315d8 (diff)
downloadmpv-d6abfcd5784b033803d325b4dbb17836fdf7031e.tar.bz2
mpv-d6abfcd5784b033803d325b4dbb17836fdf7031e.tar.xz
af_volume: use only one volume setting for all channels
In theory, af_volume could use separate volume levels for each channel. But this was never used anywhere. MPlayer implemented something similar before (svn r36498), but kept the old path for some reason.
Diffstat (limited to 'audio/mixer.c')
-rw-r--r--audio/mixer.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/audio/mixer.c b/audio/mixer.c
index 4ecfe2bdf4..a58007c9dc 100644
--- a/audio/mixer.c
+++ b/audio/mixer.c
@@ -71,12 +71,12 @@ static void checkvolume(struct mixer *mixer)
ao_control_vol_t vol = {mixer->vol_l, mixer->vol_r};
if (mixer->softvol) {
- float vals[AF_NCH];
+ float gain;
if (!af_control_any_rev(mixer->af,
- AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, vals))
- vals[0] = vals[1] = 1.0;
- vol.left = (vals[0] / (mixer->opts->softvol_max / 100.0)) * 100.0;
- vol.right = (vals[1] / (mixer->opts->softvol_max / 100.0)) * 100.0;
+ AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, &gain))
+ gain = 1.0;
+ vol.left = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
+ vol.right = (gain / (mixer->opts->softvol_max / 100.0)) * 100.0;
} else {
// Rely on the values not changing if the query is not supported
ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol);
@@ -118,20 +118,16 @@ static void setvolume_internal(struct mixer *mixer, float l, float r)
"[Mixer] Failed to change audio output volume.\n");
return;
}
- float vals[AF_NCH];
- vals[0] = l / 100.0 * mixer->opts->softvol_max / 100.0;
- vals[1] = r / 100.0 * mixer->opts->softvol_max / 100.0;
- for (int i = 2; i < AF_NCH; i++)
- vals[i] = (vals[0] + vals[1]) / 2.0;
+ float gain = (l + r) / 2.0 / 100.0 * mixer->opts->softvol_max / 100.0;
if (!af_control_any_rev(mixer->af,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET,
- vals))
+ &gain))
{
mp_tmsg(MSGT_GLOBAL, MSGL_V, "[Mixer] Inserting volume filter.\n");
if (!(af_add(mixer->af, "volume", NULL)
&& af_control_any_rev(mixer->af,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET,
- vals)))
+ &gain)))
mp_tmsg(MSGT_GLOBAL, MSGL_ERR,
"[Mixer] No volume control available.\n");
}