mirror of https://github.com/mpv-player/mpv
options: remove --mixer and --mixer-channel, turn them into alsa/oss subopts
These two options were supported by ALSA and OSS only. Further, their values were specific to the respective audio systems, so it doesn't make sense to keep them as top-level options.
This commit is contained in:
parent
5c610836cd
commit
5b91ba0a8d
|
@ -30,6 +30,15 @@ Available audio output drivers are:
|
||||||
``device=<device>``
|
``device=<device>``
|
||||||
Sets the device name. For ac3 output via S/PDIF, use an "iec958" or
|
Sets the device name. For ac3 output via S/PDIF, use an "iec958" or
|
||||||
"spdif" device, unless you really know how to set it correctly.
|
"spdif" device, unless you really know how to set it correctly.
|
||||||
|
``mixer-device=<device>``
|
||||||
|
Set the mixer device used with ``--no-softvol`` (default: ``default``).
|
||||||
|
``mixer-name=<name>``
|
||||||
|
Set the name of the mixer element (default: ``Master``). This is for
|
||||||
|
example ``PCM`` or ``Master``.
|
||||||
|
``mixer-index=<number>``
|
||||||
|
Set the index of the mixer channel (default: 0). Consider the output
|
||||||
|
"``amixer scontrols``", then the index is the number that follows the
|
||||||
|
name of the element.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -47,7 +56,9 @@ Available audio output drivers are:
|
||||||
``<mixer-device>``
|
``<mixer-device>``
|
||||||
Sets the audio mixer device (default: ``/dev/mixer``).
|
Sets the audio mixer device (default: ``/dev/mixer``).
|
||||||
``<mixer-channel>``
|
``<mixer-channel>``
|
||||||
Sets the audio mixer channel (default: ``pcm``).
|
Sets the audio mixer channel (default: ``pcm``). Other valid values
|
||||||
|
include **vol, pcm, line**. For a complete list of options look for
|
||||||
|
``SOUND_DEVICE_NAMES`` in ``/usr/include/linux/soundcard.h``.
|
||||||
|
|
||||||
``jack``
|
``jack``
|
||||||
JACK (Jack Audio Connection Kit) audio output driver
|
JACK (Jack Audio Connection Kit) audio output driver
|
||||||
|
|
|
@ -131,6 +131,8 @@ Command Line Switches
|
||||||
``-lavfdopts`` ``--demuxer-lavf-...``
|
``-lavfdopts`` ``--demuxer-lavf-...``
|
||||||
``-rawaudio ...`` ``--demuxer-rawaudio-...``
|
``-rawaudio ...`` ``--demuxer-rawaudio-...``
|
||||||
``-rawvideo ...`` ``--demuxer-rawvideo-...``
|
``-rawvideo ...`` ``--demuxer-rawvideo-...``
|
||||||
|
``--mixer`` AO suboptions (``alsa``, ``oss``)
|
||||||
|
``--mixer-channel`` AO suboptions (``alsa``, ``oss``)
|
||||||
=========================== ========================================
|
=========================== ========================================
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
|
@ -1202,24 +1202,6 @@
|
||||||
:fps=<value>: output fps (default: 25)
|
:fps=<value>: output fps (default: 25)
|
||||||
:type=<value>: input file type (available: jpeg, png, tga, sgi)
|
:type=<value>: input file type (available: jpeg, png, tga, sgi)
|
||||||
|
|
||||||
``--mixer=<device>``
|
|
||||||
Use a mixer device different from the default ``/dev/mixer``. For ALSA
|
|
||||||
this is the mixer name.
|
|
||||||
|
|
||||||
``--mixer-channel=<name[,index]>``
|
|
||||||
(``--ao=oss`` and ``--ao=alsa`` only)
|
|
||||||
This option will tell mpv to use a different channel for controlling
|
|
||||||
volume than the default PCM. Options for OSS include **vol, pcm, line**.
|
|
||||||
For a complete list of options look for ``SOUND_DEVICE_NAMES`` in
|
|
||||||
``/usr/include/linux/soundcard.h``. For ALSA, you can use the names e.g.
|
|
||||||
"``amixer scontrols``" displays, like **Master, Line, PCM**.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
ALSA mixer channel names followed by a number must be specified in the
|
|
||||||
<name,number> format, i.e. a channel labeled 'PCM 1' in alsamixer must
|
|
||||||
be converted to PCM,1.
|
|
||||||
|
|
||||||
``--monitoraspect=<ratio>``
|
``--monitoraspect=<ratio>``
|
||||||
Set the aspect ratio of your monitor or TV screen. A value of 0 disables a
|
Set the aspect ratio of your monitor or TV screen. A value of 0 disables a
|
||||||
previous setting (e.g. in the config file). Overrides the
|
previous setting (e.g. in the config file). Overrides the
|
||||||
|
|
|
@ -62,6 +62,9 @@ struct priv {
|
||||||
|
|
||||||
int cfg_block;
|
int cfg_block;
|
||||||
char *cfg_device;
|
char *cfg_device;
|
||||||
|
char *cfg_mixer_device;
|
||||||
|
char *cfg_mixer_name;
|
||||||
|
int cfg_mixer_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BUFFER_TIME 500000 // 0.5 s
|
#define BUFFER_TIME 500000 // 0.5 s
|
||||||
|
@ -102,6 +105,7 @@ static void alsa_error_handler(const char *file, int line, const char *function,
|
||||||
/* to set/get/query special features/parameters */
|
/* to set/get/query special features/parameters */
|
||||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
{
|
{
|
||||||
|
struct priv *p = ao->priv;
|
||||||
snd_mixer_t *handle = NULL;
|
snd_mixer_t *handle = NULL;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case AOCONTROL_GET_MUTE:
|
case AOCONTROL_GET_MUTE:
|
||||||
|
@ -113,10 +117,6 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
snd_mixer_elem_t *elem;
|
snd_mixer_elem_t *elem;
|
||||||
snd_mixer_selem_id_t *sid;
|
snd_mixer_selem_id_t *sid;
|
||||||
|
|
||||||
char *mix_name = "Master";
|
|
||||||
char *card = "default";
|
|
||||||
int mix_index = 0;
|
|
||||||
|
|
||||||
long pmin, pmax;
|
long pmin, pmax;
|
||||||
long get_vol, set_vol;
|
long get_vol, set_vol;
|
||||||
float f_multi;
|
float f_multi;
|
||||||
|
@ -124,41 +124,17 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
if (AF_FORMAT_IS_IEC61937(ao->format))
|
if (AF_FORMAT_IS_IEC61937(ao->format))
|
||||||
return CONTROL_TRUE;
|
return CONTROL_TRUE;
|
||||||
|
|
||||||
if (ao->opts->mixer_channel) {
|
|
||||||
char *test_mix_index;
|
|
||||||
|
|
||||||
mix_name = strdup(ao->opts->mixer_channel);
|
|
||||||
if ((test_mix_index = strchr(mix_name, ','))) {
|
|
||||||
*test_mix_index = 0;
|
|
||||||
test_mix_index++;
|
|
||||||
mix_index = strtol(test_mix_index, &test_mix_index, 0);
|
|
||||||
|
|
||||||
if (*test_mix_index) {
|
|
||||||
mp_tmsg(MSGT_AO, MSGL_ERR,
|
|
||||||
"[AO_ALSA] Invalid mixer index. Defaulting to 0.\n");
|
|
||||||
mix_index = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ao->opts->mixer_device)
|
|
||||||
card = ao->opts->mixer_device;
|
|
||||||
|
|
||||||
//allocate simple id
|
//allocate simple id
|
||||||
snd_mixer_selem_id_alloca(&sid);
|
snd_mixer_selem_id_alloca(&sid);
|
||||||
|
|
||||||
//sets simple-mixer index and name
|
//sets simple-mixer index and name
|
||||||
snd_mixer_selem_id_set_index(sid, mix_index);
|
snd_mixer_selem_id_set_index(sid, p->cfg_mixer_index);
|
||||||
snd_mixer_selem_id_set_name(sid, mix_name);
|
snd_mixer_selem_id_set_name(sid, p->cfg_mixer_name);
|
||||||
|
|
||||||
if (ao->opts->mixer_channel) {
|
|
||||||
free(mix_name);
|
|
||||||
mix_name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = snd_mixer_open(&handle, 0);
|
err = snd_mixer_open(&handle, 0);
|
||||||
CHECK_ALSA_ERROR("Mixer open error");
|
CHECK_ALSA_ERROR("Mixer open error");
|
||||||
|
|
||||||
err = snd_mixer_attach(handle, card);
|
err = snd_mixer_attach(handle, p->cfg_mixer_device);
|
||||||
CHECK_ALSA_ERROR("Mixer attach error");
|
CHECK_ALSA_ERROR("Mixer attach error");
|
||||||
|
|
||||||
err = snd_mixer_selem_register(handle, NULL, NULL);
|
err = snd_mixer_selem_register(handle, NULL, NULL);
|
||||||
|
@ -791,10 +767,18 @@ const struct ao_driver audio_out_alsa = {
|
||||||
.resume = audio_resume,
|
.resume = audio_resume,
|
||||||
.reset = reset,
|
.reset = reset,
|
||||||
.priv_size = sizeof(struct priv),
|
.priv_size = sizeof(struct priv),
|
||||||
.priv_defaults = &(const struct priv) { .cfg_block = 1 },
|
.priv_defaults = &(const struct priv) {
|
||||||
|
.cfg_block = 1,
|
||||||
|
.cfg_mixer_device = "default",
|
||||||
|
.cfg_mixer_name = "Master",
|
||||||
|
.cfg_mixer_index = 0,
|
||||||
|
},
|
||||||
.options = (const struct m_option[]) {
|
.options = (const struct m_option[]) {
|
||||||
OPT_STRING("device", cfg_device, 0),
|
OPT_STRING("device", cfg_device, 0),
|
||||||
OPT_FLAG("block", cfg_block, 0),
|
OPT_FLAG("block", cfg_block, 0),
|
||||||
|
OPT_STRING("mixer-device", cfg_mixer_device, 0),
|
||||||
|
OPT_STRING("mixer-name", cfg_mixer_name, 0),
|
||||||
|
OPT_INTRANGE("mixer-index", cfg_mixer_index, 0, 0, 99),
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,10 +193,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||||
// return: 0=success -1=fail
|
// return: 0=success -1=fail
|
||||||
static int init(struct ao *ao, char *params)
|
static int init(struct ao *ao, char *params)
|
||||||
{
|
{
|
||||||
struct MPOpts *opts = ao->opts;
|
|
||||||
char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
|
char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
|
||||||
int oss_format;
|
int oss_format;
|
||||||
char *mdev = opts->mixer_device, *mchan = opts->mixer_channel;
|
char *mdev = PATH_DEV_MIXER;
|
||||||
|
char *mchan = talloc_strdup(ao, mixer_channels[SOUND_MIXER_PCM]);
|
||||||
|
|
||||||
mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz %d chans %s\n", ao->samplerate,
|
mp_msg(MSGT_AO, MSGL_V, "ao2: %d Hz %d chans %s\n", ao->samplerate,
|
||||||
ao->channels.num, af_fmt2str_short(ao->format));
|
ao->channels.num, af_fmt2str_short(ao->format));
|
||||||
|
@ -205,8 +205,6 @@ static int init(struct ao *ao, char *params)
|
||||||
*p = (struct priv) {
|
*p = (struct priv) {
|
||||||
.dsp = PATH_DEV_DSP,
|
.dsp = PATH_DEV_DSP,
|
||||||
.audio_fd = -1,
|
.audio_fd = -1,
|
||||||
.oss_mixer_device = mdev ? mdev : PATH_DEV_MIXER,
|
|
||||||
.oss_mixer_channel = SOUND_MIXER_PCM,
|
|
||||||
.audio_delay_method = 2,
|
.audio_delay_method = 2,
|
||||||
.buffersize = -1,
|
.buffersize = -1,
|
||||||
.outburst = 512,
|
.outburst = 512,
|
||||||
|
@ -227,6 +225,7 @@ static int init(struct ao *ao, char *params)
|
||||||
}
|
}
|
||||||
p->dsp = talloc_strdup(ao, params);
|
p->dsp = talloc_strdup(ao, params);
|
||||||
}
|
}
|
||||||
|
p->oss_mixer_device = talloc_strdup(p, mdev);
|
||||||
|
|
||||||
if (mchan) {
|
if (mchan) {
|
||||||
int fd, devs, i;
|
int fd, devs, i;
|
||||||
|
|
|
@ -526,8 +526,6 @@ const m_option_t mp_opts[] = {
|
||||||
OPT_FLAG("ontop", vo.ontop, 0),
|
OPT_FLAG("ontop", vo.ontop, 0),
|
||||||
OPT_FLAG("border", vo.border, 0),
|
OPT_FLAG("border", vo.border, 0),
|
||||||
|
|
||||||
OPT_STRING("mixer", mixer_device, 0),
|
|
||||||
OPT_STRING("mixer-channel", mixer_channel, 0),
|
|
||||||
OPT_CHOICE("softvol", softvol, 0,
|
OPT_CHOICE("softvol", softvol, 0,
|
||||||
({"no", SOFTVOL_NO},
|
({"no", SOFTVOL_NO},
|
||||||
{"yes", SOFTVOL_YES},
|
{"yes", SOFTVOL_YES},
|
||||||
|
|
|
@ -49,8 +49,6 @@ typedef struct MPOpts {
|
||||||
|
|
||||||
struct m_obj_settings *audio_driver_list;
|
struct m_obj_settings *audio_driver_list;
|
||||||
int fixed_vo;
|
int fixed_vo;
|
||||||
char *mixer_device;
|
|
||||||
char *mixer_channel;
|
|
||||||
int softvol;
|
int softvol;
|
||||||
float mixer_init_volume;
|
float mixer_init_volume;
|
||||||
int mixer_init_mute;
|
int mixer_init_mute;
|
||||||
|
|
Loading…
Reference in New Issue