summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-17 19:21:28 +0200
committerwm4 <wm4@nowhere>2016-07-17 19:21:28 +0200
commit77e1e8e38e7b8d9318dc1bb437a88d8f13b7a5c9 (patch)
treed64c47c331174f59eeecb9a713ba76aa4b7110cb /player/command.c
parent79974e7ad94e7658c780e3b446a7822a533675e4 (diff)
downloadmpv-77e1e8e38e7b8d9318dc1bb437a88d8f13b7a5c9.tar.bz2
mpv-77e1e8e38e7b8d9318dc1bb437a88d8f13b7a5c9.tar.xz
audio: refactor mixer code and delete mixer.c
mixer.c didn't really deserve to be separate anymore, as half of its contents were unnecessary glue code after recent changes. It also created a weird split between audio.c and af.c due to the fact that mixer.c could insert audio filters. With the code being in audio.c directly, together with other code that unserts filters during runtime, it will be possible to cleanup this code a bit and make it work like the video filter code. As part of this change, make the balance code work like the volume code, and add an option to back the current balance value. Also, since the balance semantics are unexpected for most users (panning between the audio channels, instead of just changing the relative volume), and there are some other volumes, formally deprecate both the old property and the new option.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/player/command.c b/player/command.c
index a815ae8a1d..d8f4f83529 100644
--- a/player/command.c
+++ b/player/command.c
@@ -54,7 +54,6 @@
#include "video/decode/vd.h"
#include "video/out/vo.h"
#include "video/csputils.h"
-#include "audio/mixer.h"
#include "audio/audio_buffer.h"
#include "audio/out/ao.h"
#include "audio/filter/af.h"
@@ -1561,7 +1560,8 @@ static int mp_property_mixer_active(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- return m_property_flag_ro(action, arg, mixer_audio_initialized(mpctx->mixer));
+ struct ao_chain *ao_c = mpctx->ao_chain;
+ return m_property_flag_ro(action, arg, ao_c && ao_c->af->initialized > 0);
}
/// Volume (RW)
@@ -1590,7 +1590,7 @@ static int mp_property_volume(void *ctx, struct m_property *prop,
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET)
- mixer_update_volume(mpctx->mixer);
+ audio_update_volume(mpctx);
return r;
}
@@ -1607,7 +1607,7 @@ static int mp_property_mute(void *ctx, struct m_property *prop,
int r = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET)
- mixer_update_volume(mpctx->mixer);
+ audio_update_volume(mpctx);
return r;
}
@@ -1841,23 +1841,10 @@ static int mp_property_balance(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- float bal;
- switch (action) {
- case M_PROPERTY_GET:
- mixer_getbalance(mpctx->mixer, arg);
- return M_PROPERTY_OK;
- case M_PROPERTY_GET_TYPE:
- *(struct m_option *)arg = (struct m_option){
- .type = CONF_TYPE_FLOAT,
- .flags = M_OPT_RANGE,
- .min = -1,
- .max = 1,
- };
- return M_PROPERTY_OK;
- case M_PROPERTY_PRINT: {
+ if (action == M_PROPERTY_PRINT) {
char **str = arg;
- mixer_getbalance(mpctx->mixer, &bal);
+ float bal = mpctx->opts->balance;
if (bal == 0.f)
*str = talloc_strdup(NULL, "center");
else if (bal == -1.f)
@@ -1871,11 +1858,11 @@ static int mp_property_balance(void *ctx, struct m_property *prop,
}
return M_PROPERTY_OK;
}
- case M_PROPERTY_SET:
- mixer_setbalance(mpctx->mixer, *(float *)arg);
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+
+ int r = mp_property_generic_option(mpctx, prop, action, arg);
+ if (action == M_PROPERTY_SET)
+ audio_update_balance(mpctx);
+ return r;
}
static struct track* track_next(struct MPContext *mpctx, enum stream_type type,