summaryrefslogtreecommitdiffstats
path: root/player
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 /player
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 'player')
-rw-r--r--player/command.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/player/command.c b/player/command.c
index 9ade4c08df..c3a6729805 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1616,17 +1616,14 @@ static int mp_property_ao_volume(void *ctx, struct m_property *prop,
switch (action) {
case M_PROPERTY_SET: {
- float value = *(float *)arg;
- ao_control_vol_t vol = {value, value};
+ float vol = *(float *)arg;
if (ao_control(ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
return M_PROPERTY_OK;
}
case M_PROPERTY_GET: {
- ao_control_vol_t vol = {0};
- if (ao_control(ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK)
+ if (ao_control(ao, AOCONTROL_GET_VOLUME, arg) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
- *(float *)arg = (vol.left + vol.right) / 2.0f;
return M_PROPERTY_OK;
}
case M_PROPERTY_GET_TYPE:
@@ -1637,10 +1634,10 @@ static int mp_property_ao_volume(void *ctx, struct m_property *prop,
};
return M_PROPERTY_OK;
case M_PROPERTY_PRINT: {
- ao_control_vol_t vol = {0};
+ float vol = 0;
if (ao_control(ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK)
return M_PROPERTY_UNAVAILABLE;
- *(char **)arg = talloc_asprintf(NULL, "%.f", (vol.left + vol.right) / 2.0f);
+ *(char **)arg = talloc_asprintf(NULL, "%.f", vol);
return M_PROPERTY_OK;
}
}