From: Clemens Ladisch Date: Mon, 12 Oct 2009 06:48:46 +0000 (+0200) Subject: hcontrol: allow constructing Elem with numid X-Git-Tag: v1.0.22~2 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=2910c22c50c968b1dcaf37a59e9a6c0f0ef3d53d;p=alsa-python.git hcontrol: allow constructing Elem with numid 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 --- diff --git a/pyalsa/alsahcontrol.c b/pyalsa/alsahcontrol.c index f06c354..ee66d47 100644 --- a/pyalsa/alsahcontrol.c +++ b/pyalsa/alsahcontrol.c @@ -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