From: Takashi Iwai Date: Tue, 17 Feb 2009 16:29:17 +0000 (+0100) Subject: oss: Add numid check in ctl plugin X-Git-Tag: v1.0.20~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=63257a7b4b47cd654c96511366645eb2b6025956;p=alsa-plugins.git oss: Add numid check in ctl plugin Added the check of non-zero numid to optimize the look-up for the element. Signed-off-by: Takashi Iwai --- diff --git a/oss/ctl_oss.c b/oss/ctl_oss.c index b589f74..b8847b1 100644 --- a/oss/ctl_oss.c +++ b/oss/ctl_oss.c @@ -151,7 +151,21 @@ static snd_ctl_ext_key_t oss_find_elem(snd_ctl_ext_t *ext, { snd_ctl_oss_t *oss = ext->private_data; const char *name; - unsigned int i, key; + unsigned int i, key, numid; + + numid = snd_ctl_elem_id_get_numid(id); + if (numid > 0) { + numid--; + if (numid < oss->num_vol_ctls) + return oss->vol_ctl[numid]; + numid -= oss->num_vol_ctls; + if (oss->exclusive_input) { + if (!numid) + return OSS_KEY_CAPTURE_MUX; + } else if (numid < oss->num_rec_items) + return oss->rec_item[numid] | + OSS_KEY_CAPTURE_FLAG; + } name = snd_ctl_elem_id_get_name(id); if (! strcmp(name, "Capture Source")) {