]> git.alsa-project.org Git - alsa-python.git/commitdiff
hcontrol: allow constructing Elem with numid
authorClemens Ladisch <clemens@ladisch.de>
Mon, 12 Oct 2009 06:48:46 +0000 (08:48 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Mon, 12 Oct 2009 06:48:46 +0000 (08:48 +0200)
snd_hctl_find_elem has the (undocumented) requirement that the ID must
have all fields set.  Copy the necessary workaround from amixer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
pyalsa/alsahcontrol.c

index f06c354b622b4238f216934c83726772200993f5..ee66d478aad83f648ed24bda2e5c4f3ff768a15a 100644 (file)
@@ -573,6 +573,7 @@ pyalsahcontrolelement_init(struct pyalsahcontrolelement *pyhelem, PyObject *args
        static char *kwlist1[] = { "hctl", "interface", "device", "subdevice", "name", "index", NULL };
        long helem = 0;
        float f = 0;
+       snd_ctl_elem_info_t *elem_info;
 
        snd_ctl_elem_id_alloca(&id);
        pyhelem->pyhandle = NULL;
@@ -617,9 +618,17 @@ pyalsahcontrolelement_init(struct pyalsahcontrolelement *pyhelem, PyObject *args
        Py_INCREF(hctl);
        pyhelem->handle = PYHCTL(hctl)->handle;
 
+       /* FIXME: Remove it when hctl find works ok !!! */
+       snd_ctl_elem_info_alloca(&elem_info);
+       snd_ctl_elem_info_set_id(elem_info, id);
+       if (snd_ctl_elem_info(snd_hctl_ctl(pyhelem->handle), elem_info) < 0)
+               goto elem_not_found;
+       snd_ctl_elem_info_get_id(elem_info, id);
+
        pyhelem->elem = helem > 0 ? (snd_hctl_elem_t *)helem :
                                snd_hctl_find_elem(pyhelem->handle, id);
        if (pyhelem->elem == NULL) {
+elem_not_found:
                if (numid == 0)
                        PyErr_Format(PyExc_IOError, "cannot find hcontrol element %i,%i,%i,'%s',%i", iface, device, subdevice, name, index);
                else