summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/ao.rst13
-rw-r--r--DOCS/man/en/changes.rst2
-rw-r--r--DOCS/man/en/options.rst18
-rw-r--r--audio/out/ao_alsa.c48
-rw-r--r--audio/out/ao_oss.c7
-rw-r--r--core/options.c2
-rw-r--r--core/options.h2
7 files changed, 33 insertions, 59 deletions
diff --git a/DOCS/man/en/ao.rst b/DOCS/man/en/ao.rst
index 82f77c6e6d..0d7720c4ee 100644
--- a/DOCS/man/en/ao.rst
+++ b/DOCS/man/en/ao.rst
@@ -30,6 +30,15 @@ Available audio output drivers are:
``device=<device>``
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.
+ ``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::
@@ -47,7 +56,9 @@ Available audio output drivers are:
``<mixer-device>``
Sets the audio mixer device (default: ``/dev/mixer``).
``<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 Audio Connection Kit) audio output driver
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst
index eeac7fada9..26c9e9d9d2 100644
--- a/DOCS/man/en/changes.rst
+++ b/DOCS/man/en/changes.rst
@@ -131,6 +131,8 @@ Command Line Switches
``-lavfdopts`` ``--demuxer-lavf-...``
``-rawaudio ...`` ``--demuxer-rawaudio-...``
``-rawvideo ...`` ``--demuxer-rawvideo-...``
+ ``--mixer`` AO suboptions (``alsa``, ``oss``)
+ ``--mixer-channel`` AO suboptions (``alsa``, ``oss``)
=========================== ========================================
.. note::
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index bb908f3885..394cc720f4 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1202,24 +1202,6 @@
:fps=<value>: output fps (default: 25)
: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>``
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
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index b3544fad24..7428c29a29 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -62,6 +62,9 @@ struct priv {
int cfg_block;
char *cfg_device;
+ char *cfg_mixer_device;
+ char *cfg_mixer_name;
+ int cfg_mixer_index;
};
#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 */
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
+ struct priv *p = ao->priv;
snd_mixer_t *handle = NULL;
switch (cmd) {
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_selem_id_t *sid;
- char *mix_name = "Master";
- char *card = "default";
- int mix_index = 0;
-
long pmin, pmax;
long get_vol, set_vol;
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))
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
snd_mixer_selem_id_alloca(&sid);
//sets simple-mixer index and name
- snd_mixer_selem_id_set_index(sid, mix_index);
- snd_mixer_selem_id_set_name(sid, mix_name);
-
- if (ao->opts->mixer_channel) {
- free(mix_name);
- mix_name = NULL;
- }
+ snd_mixer_selem_id_set_index(sid, p->cfg_mixer_index);
+ snd_mixer_selem_id_set_name(sid, p->cfg_mixer_name);
err = snd_mixer_open(&handle, 0);
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");
err = snd_mixer_selem_register(handle, NULL, NULL);
@@ -791,10 +767,18 @@ const struct ao_driver audio_out_alsa = {
.resume = audio_resume,
.reset = reset,
.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[]) {
OPT_STRING("device", cfg_device, 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}
},
};
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index fa590f7965..6a46bd4db1 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -193,10 +193,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
// return: 0=success -1=fail
static int init(struct ao *ao, char *params)
{
- struct MPOpts *opts = ao->opts;
char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
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,
ao->channels.num, af_fmt2str_short(ao->format));
@@ -205,8 +205,6 @@ static int init(struct ao *ao, char *params)
*p = (struct priv) {
.dsp = PATH_DEV_DSP,
.audio_fd = -1,
- .oss_mixer_device = mdev ? mdev : PATH_DEV_MIXER,
- .oss_mixer_channel = SOUND_MIXER_PCM,
.audio_delay_method = 2,
.buffersize = -1,
.outburst = 512,
@@ -227,6 +225,7 @@ static int init(struct ao *ao, char *params)
}
p->dsp = talloc_strdup(ao, params);
}
+ p->oss_mixer_device = talloc_strdup(p, mdev);
if (mchan) {
int fd, devs, i;
diff --git a/core/options.c b/core/options.c
index eceb1f259f..2fa6e319ab 100644
--- a/core/options.c
+++ b/core/options.c
@@ -526,8 +526,6 @@ const m_option_t mp_opts[] = {
OPT_FLAG("ontop", vo.ontop, 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,
({"no", SOFTVOL_NO},
{"yes", SOFTVOL_YES},
diff --git a/core/options.h b/core/options.h
index 44ca1148b9..212c3c79c9 100644
--- a/core/options.h
+++ b/core/options.h
@@ -49,8 +49,6 @@ typedef struct MPOpts {
struct m_obj_settings *audio_driver_list;
int fixed_vo;
- char *mixer_device;
- char *mixer_channel;
int softvol;
float mixer_init_volume;
int mixer_init_mute;