forked from auracaster/pyalsaaudio
Better (but not 100% backward compatible) device selection for mixers/PCM
This commit is contained in:
12
alsaaudio.c
12
alsaaudio.c
@@ -933,10 +933,10 @@ alsamixer_list(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
char *device = "default";
|
||||
PyObject *result;
|
||||
|
||||
char *kw[] = { "device", "cardindex", NULL };
|
||||
char *kw[] = { "cardindex", "device", NULL };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|si", kw,
|
||||
&device, &cardidx))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|is", kw,
|
||||
&cardidx, &device))
|
||||
return NULL;
|
||||
|
||||
if (cardidx >= 0) {
|
||||
@@ -1006,10 +1006,10 @@ alsamixer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
int id = 0;
|
||||
snd_mixer_elem_t *elem;
|
||||
int channel;
|
||||
char *kw[] = { "control", "id", "device", "cardindex", NULL };
|
||||
char *kw[] = { "control", "id", "cardindex", "device", NULL };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sisi", kw,
|
||||
&control, &id, &device, &cardidx))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|siis", kw,
|
||||
&control, &id, &cardidx, &device))
|
||||
return NULL;
|
||||
|
||||
if (cardidx >= 0) {
|
||||
|
||||
@@ -38,22 +38,21 @@ The :mod:`alsaaudio` module defines functions and classes for using ALSA.
|
||||
|
||||
List the available cards by name (suitable for PCM objects).
|
||||
|
||||
.. function:: mixers(device='default', cardindex=-1)
|
||||
.. function:: mixers(cardindex=-1, device='default')
|
||||
|
||||
List the available mixers. The arguments are:
|
||||
|
||||
*device* - the name of the device on which the mixer resides. The default is
|
||||
'default'.
|
||||
|
||||
*cardindex* - specifies which card should be used [#f3]_. If this argument
|
||||
is given, the device name is constructed like this: `hw:<cardindex>` and
|
||||
the `device` keyword argument is ignored. 0 is the
|
||||
first sound card.
|
||||
|
||||
**Note:** The arguments for this function were changed in
|
||||
version 0.8 and this change is not completely backward compatible.
|
||||
Old versions accepted just the optional parameter *cardindex*.
|
||||
The current version accepts either a device name or a cardindex.
|
||||
*device* - the name of the device on which the mixer resides. The default is
|
||||
'default'.
|
||||
|
||||
**Note:** The arguments for this function were extended in
|
||||
version 0.8. The keyword argument `device` is new and can be used to select
|
||||
virtual devices.
|
||||
|
||||
.. class:: PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, card='default')
|
||||
|
||||
@@ -64,7 +63,7 @@ The :mod:`alsaaudio` module defines functions and classes for using ALSA.
|
||||
* *mode* - can be either ``PCM_NONBLOCK``, or ``PCM_NORMAL`` (default).
|
||||
* *card* - specifies the name of the card that should be used.
|
||||
|
||||
.. class:: Mixer(control='Master', id=0, device='default', cardindex=-1)
|
||||
.. class:: Mixer(control='Master', id=0, cardindex=-1, device='default')
|
||||
|
||||
This class is used to access a specific ALSA mixer. The arguments
|
||||
are:
|
||||
|
||||
Reference in New Issue
Block a user