summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_oss.c
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2022-12-31 03:46:44 +0000
committerPhilip Langdale <github.philipl@overt.org>2023-01-25 15:49:21 -0800
commit870512eb84a5b8bc4d4fdd794eb11bb3598e234b (patch)
treec68417de22549377028006b72b51657535ecd3b7 /audio/out/ao_oss.c
parent5510d9f6632c009c398ce48a4d5a89c7f95efc96 (diff)
downloadmpv-870512eb84a5b8bc4d4fdd794eb11bb3598e234b.tar.bz2
mpv-870512eb84a5b8bc4d4fdd794eb11bb3598e234b.tar.xz
audio: simplify implementation of property ao-volume
ao-volume is represented in the code with a `struct ao_control_vol_t` which contains volumes for two channels, left and right. However the code implementing this property in command.c never treats these values individually. They are always averaged together. On the other hand the code in the AOs handling these values also has to handle the case where *not* exactly two channels are handled. So let's remove the `struct ao_control_vol_t` and replace it with a simple float. This makes the semantics clear to AO authors and allows us to drop some code from the AOs and command.c.
Diffstat (limited to 'audio/out/ao_oss.c')
-rw-r--r--audio/out/ao_oss.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index 2d1a60db4d..b0077cc853 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -267,7 +267,7 @@ static void uninit(struct ao *ao)
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct priv *p = ao->priv;
- ao_control_vol_t *vol = (ao_control_vol_t *)arg;
+ float *vol = arg;
int v;
if (p->dsp_fd < 0)
@@ -279,11 +279,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
MP_WARN_IOCTL_ERR(ao);
return CONTROL_ERROR;
}
- vol->right = ((v & 0xff00) >> 8);
- vol->left = (v & 0x00ff);
+ *vol = ((v & 0x00ff) + ((v & 0xff00) >> 8)) / 2.0;
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
- v = ((int)vol->right << 8) | (int)vol->left;
+ v = ((int)*vol << 8) | (int)*vol;
if (ioctl(p->dsp_fd, SNDCTL_DSP_SETPLAYVOL, &v) == -1) {
MP_WARN_IOCTL_ERR(ao);
return CONTROL_ERROR;