alsa/0024-PCM-Fix-the-conversion-from-string-to-chmap-position.patch
Takashi Iwai 8a90d87ca6 Accepting request 138456 from home:tiwai:branches:multimedia:libs
- backport from upstream tree:
  * lots of patches to support the new chmap API
  * fix segfault in rate plugin error path
  * add a couple of test programs
  * fix inifinte loop in htimestamp of dmix & co

OBS-URL: https://build.opensuse.org/request/show/138456
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=113
2012-10-17 08:17:46 +00:00

68 lines
1.7 KiB
Diff

From c6db60e32758e8f4bb6f066a5c6fc7758a0f4c49 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 12 Sep 2012 18:44:42 +0200
Subject: [PATCH 24/30] PCM: Fix the conversion from string to chmap position
Use strncasecmp() to allow lower cases, and also evaluate the inverted
phase suffix, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/pcm/pcm.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -7471,24 +7471,41 @@ int snd_pcm_chmap_print(const snd_pcm_ch
static int str_to_chmap(const char *str, int len)
{
int val;
+ unsigned long v;
+ char *p;
if (isdigit(*str)) {
- val = atoi(str);
- if (val < 0)
+ v = strtoul(str, &p, 0);
+ if (v == ULONG_MAX)
return -1;
- return val | SND_CHMAP_DRIVER_SPEC;
- } else if (str[0] == 'C' && str[1] == 'h') {
- val = atoi(str + 2);
- if (val < 0)
+ val = v;
+ val |= SND_CHMAP_DRIVER_SPEC;
+ str = p;
+ } else if (!strncasecmp(str, "ch", 2)) {
+ v = strtoul(str + 2, &p, 0);
+ if (v == ULONG_MAX)
return -1;
- return val;
+ val = v;
+ str = p;
} else {
for (val = 0; val <= SND_CHMAP_LAST; val++) {
- if (!strncmp(str, chmap_names[val], len))
- return val;
+ int slen;
+ assert(chmap_names[val]);
+ slen = strlen(chmap_names[val]);
+ if (slen > len)
+ continue;
+ if (!strncasecmp(str, chmap_names[val], slen) &&
+ !isalpha(str[slen])) {
+ str += slen;
+ break;
+ }
}
- return -1;
+ if (val > SND_CHMAP_LAST)
+ return -1;
}
+ if (str && !strncasecmp(str, "[INV]", 5))
+ val |= SND_CHMAP_PHASE_INVERSE;
+ return val;
}
unsigned int snd_pcm_chmap_from_string(const char *str)