mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
alsa-mixer: improve alsa_id_decode() function
Accept those identifiers:
Speaker,1
'Speaker',1
"Speaker",1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
7f4b8e1a7c
commit
1c240b7a12
1 changed files with 16 additions and 3 deletions
|
|
@ -117,11 +117,24 @@ static char *alsa_id_str(char *dst, size_t dst_len, pa_alsa_mixer_id *id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alsa_id_decode(const char *src, char *name, int *index) {
|
static int alsa_id_decode(const char *src, char *name, int *index) {
|
||||||
char *idx;
|
char *idx, c;
|
||||||
|
int i;
|
||||||
|
|
||||||
*index = 0;
|
*index = 0;
|
||||||
|
c = src[0];
|
||||||
|
/* Strip quotes in entries such as 'Speaker',1 or "Speaker",1 */
|
||||||
|
if (c == '\'' || c == '"') {
|
||||||
|
strcpy(name, src + 1);
|
||||||
|
for (i = 0; name[i] != '\0' && name[i] != c; i++);
|
||||||
|
idx = NULL;
|
||||||
|
if (name[i]) {
|
||||||
|
name[i] = '\0';
|
||||||
|
idx = strchr(name + i + 1, ',');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
strcpy(name, src);
|
strcpy(name, src);
|
||||||
idx = strchr(name, ',');
|
idx = strchr(name, ',');
|
||||||
|
}
|
||||||
if (idx == NULL)
|
if (idx == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
*idx = '\0';
|
*idx = '\0';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue