0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

options: move mixer.h options to struct

This commit is contained in:
Uoti Urpala 2012-01-21 09:28:07 +02:00
parent 7a699cea28
commit ec58e5a384
8 changed files with 30 additions and 24 deletions

View File

@ -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),

View File

@ -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,

View File

@ -80,6 +80,7 @@ struct ao {
bool untimed;
const struct ao_driver *driver;
void *priv;
struct MPOpts *opts;
};
extern char *ao_subdevice;

View File

@ -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, \

23
mixer.c
View File

@ -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)) {

View File

@ -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;

View File

@ -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;

View File

@ -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;