summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-01-21 09:28:07 +0200
committerUoti Urpala <uau@mplayer2.org>2012-03-20 14:51:32 +0200
commitec58e5a3848f82681839eaa15d2c6912d92e74ed (patch)
tree82bd6ea3411d9c2c5fcd18b9d4cb3f166db57ee3
parent7a699cea2849b2ef3f0a7a0702b74c33327ef8a9 (diff)
downloadmpv-ec58e5a3848f82681839eaa15d2c6912d92e74ed.tar.bz2
mpv-ec58e5a3848f82681839eaa15d2c6912d92e74ed.tar.xz
options: move mixer.h options to struct
-rw-r--r--cfg-mplayer.h9
-rw-r--r--defaultopts.c1
-rw-r--r--libao2/audio_out.h1
-rw-r--r--libao2/audio_out_internal.h4
-rw-r--r--mixer.c23
-rw-r--r--mixer.h9
-rw-r--r--mplayer.c3
-rw-r--r--options.h4
8 files changed, 30 insertions, 24 deletions
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 2f1ba666bb..6a167ece54 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -728,11 +728,10 @@ const m_option_t mplayer_opts[]={
{"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL},
- {"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"mixer-channel", &mixer_channel, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"nosoftvol", &soft_vol, CONF_TYPE_FLAG, 0, 1, 0, NULL},
- {"softvol-max", &soft_vol_max, CONF_TYPE_FLOAT, CONF_RANGE, 10, 10000, NULL},
+ OPT_STRING("mixer", mixer_device, 0),
+ OPT_STRING("mixer-channel", mixer_channel, 0),
+ OPT_MAKE_FLAGS("softvol", softvol, 0),
+ OPT_FLOATRANGE("softvol-max", softvol_max, 0, 10, 10000),
{"volstep", &volstep, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
{"volume", &start_volume, CONF_TYPE_FLOAT, CONF_RANGE, -1, 10000, NULL},
OPT_MAKE_FLAGS("gapless-audio", gapless_audio, 0),
diff --git a/defaultopts.c b/defaultopts.c
index 52e63cc489..b6f58b715d 100644
--- a/defaultopts.c
+++ b/defaultopts.c
@@ -10,6 +10,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.audio_driver_list = NULL,
.video_driver_list = NULL,
.fixed_vo = 1,
+ .softvol_max = 110,
.ao_buffersize = -1,
.monitor_pixel_aspect = 1.0,
.vo_panscanrange = 1.0,
diff --git a/libao2/audio_out.h b/libao2/audio_out.h
index e96e123700..cbd913656b 100644
--- a/libao2/audio_out.h
+++ b/libao2/audio_out.h
@@ -80,6 +80,7 @@ struct ao {
bool untimed;
const struct ao_driver *driver;
void *priv;
+ struct MPOpts *opts;
};
extern char *ao_subdevice;
diff --git a/libao2/audio_out_internal.h b/libao2/audio_out_internal.h
index 67bcfa953d..215428fb0e 100644
--- a/libao2/audio_out_internal.h
+++ b/libao2/audio_out_internal.h
@@ -19,6 +19,8 @@
#ifndef MPLAYER_AUDIO_OUT_INTERNAL_H
#define MPLAYER_AUDIO_OUT_INTERNAL_H
+#include "options.h"
+
// prototypes:
//static ao_info_t info;
static int control(int cmd, void *arg);
@@ -33,6 +35,8 @@ static void audio_resume(void);
extern struct ao *global_ao;
#define ao_data (*global_ao)
+#define mixer_channel (global_ao->opts->mixer_channel)
+#define mixer_device (global_ao->opts->mixer_device)
#define LIBAO_EXTERN(x) const struct ao_driver audio_out_##x = { \
.info = &info, \
diff --git a/mixer.c b/mixer.c
index 0a893cc90b..f28fea7b09 100644
--- a/mixer.c
+++ b/mixer.c
@@ -25,11 +25,6 @@
#include "mixer.h"
-char *mixer_device = NULL;
-char *mixer_channel = NULL;
-int soft_vol = 0;
-float soft_vol_max = 110.0;
-
void mixer_getvolume(mixer_t *mixer, float *l, float *r)
{
*l = 0;
@@ -38,16 +33,16 @@ void mixer_getvolume(mixer_t *mixer, float *l, float *r)
return;
ao_control_vol_t vol;
- if (soft_vol || CONTROL_OK != ao_control(mixer->ao, AOCONTROL_GET_VOLUME,
- &vol)) {
+ if (mixer->softvol || CONTROL_OK != ao_control(mixer->ao,
+ AOCONTROL_GET_VOLUME, &vol)) {
float db_vals[AF_NCH];
if (!af_control_any_rev(mixer->afilter,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, db_vals))
db_vals[0] = db_vals[1] = 1.0;
else
af_from_dB(2, db_vals, db_vals, 20.0, -200.0, 60.0);
- vol.left = (db_vals[0] / (soft_vol_max / 100.0)) * 100.0;
- vol.right = (db_vals[1] / (soft_vol_max / 100.0)) * 100.0;
+ vol.left = (db_vals[0] / (mixer->softvol_max / 100.0)) * 100.0;
+ vol.right = (db_vals[1] / (mixer->softvol_max / 100.0)) * 100.0;
}
*r = vol.right;
*l = vol.left;
@@ -62,15 +57,15 @@ void mixer_setvolume(mixer_t *mixer, float l, float r)
ao_control_vol_t vol;
vol.right = r;
vol.left = l;
- if (soft_vol || CONTROL_OK != ao_control(mixer->ao, AOCONTROL_SET_VOLUME,
- &vol)) {
+ if (mixer->softvol || CONTROL_OK != ao_control(mixer->ao,
+ AOCONTROL_SET_VOLUME, &vol)) {
// af_volume uses values in dB
float db_vals[AF_NCH];
int i;
- db_vals[0] = (l / 100.0) * (soft_vol_max / 100.0);
- db_vals[1] = (r / 100.0) * (soft_vol_max / 100.0);
+ db_vals[0] = (l / 100.0) * (mixer->softvol_max / 100.0);
+ db_vals[1] = (r / 100.0) * (mixer->softvol_max / 100.0);
for (i = 2; i < AF_NCH; i++)
- db_vals[i] = ((l + r) / 100.0) * (soft_vol_max / 100.0) / 2.0;
+ db_vals[i] = ((l + r) / 100.0) * (mixer->softvol_max / 100.0) / 2.0;
af_to_dB(AF_NCH, db_vals, db_vals, 20.0);
if (!af_control_any_rev(mixer->afilter,
AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
diff --git a/mixer.h b/mixer.h
index d7a88f74df..eaf81c1ba1 100644
--- a/mixer.h
+++ b/mixer.h
@@ -19,18 +19,17 @@
#ifndef MPLAYER_MIXER_H
#define MPLAYER_MIXER_H
+#include <stdbool.h>
+
#include "libaf/af.h"
#include "libao2/audio_out.h"
-extern char * mixer_device;
-extern char * mixer_channel;
-extern int soft_vol;
-extern float soft_vol_max;
-
typedef struct mixer {
struct ao *ao;
af_stream_t *afilter;
int volstep;
+ bool softvol;
+ float softvol_max;
int muted;
float last_l, last_r;
} mixer_t;
diff --git a/mplayer.c b/mplayer.c
index 76c2001c69..7ca2d0303f 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1776,6 +1776,7 @@ void reinit_audio_chain(struct MPContext *mpctx)
if (!(mpctx->initialized_flags & INITIALIZED_AO)) {
mpctx->initialized_flags |= INITIALIZED_AO;
mpctx->ao = ao_create();
+ mpctx->ao->opts = opts;
mpctx->ao->samplerate = force_srate;
mpctx->ao->format = opts->audio_output_format;
}
@@ -1823,6 +1824,8 @@ void reinit_audio_chain(struct MPContext *mpctx)
}
mpctx->mixer.ao = ao;
mpctx->mixer.volstep = volstep;
+ mpctx->mixer.softvol = opts->softvol;
+ mpctx->mixer.softvol_max = opts->softvol_max;
mpctx->syncing_audio = true;
return;
diff --git a/options.h b/options.h
index 9f1352d98f..8b8d2f5c3b 100644
--- a/options.h
+++ b/options.h
@@ -6,6 +6,10 @@ typedef struct MPOpts {
char **audio_driver_list;
int fixed_vo;
int vo_ontop;
+ char *mixer_device;
+ char *mixer_channel;
+ int softvol;
+ float softvol_max;
int gapless_audio;
int ao_buffersize;
int screen_size_x;