Replace unsafe characters with _ in card name

Otherwise, they get misinterpreted as argument separators
in USB-Audio PCM definitions, and thus prevent SPDIF blacklist entries
from working.

While at it, add my Logitec C910 webcam to the SPDIF blacklist.

Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Alexander E. Patrakov 2015-06-29 22:53:53 +05:00 committed by Takashi Iwai
parent c6df827374
commit 4dc44bb34a
4 changed files with 36 additions and 2 deletions

View file

@ -126,6 +126,7 @@ int snd_config_imake_integer(snd_config_t **config, const char *key, const long
int snd_config_imake_integer64(snd_config_t **config, const char *key, const long long value); int snd_config_imake_integer64(snd_config_t **config, const char *key, const long long value);
int snd_config_imake_real(snd_config_t **config, const char *key, const double value); int snd_config_imake_real(snd_config_t **config, const char *key, const double value);
int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii); int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii);
int snd_config_imake_safe_string(snd_config_t **config, const char *key, const char *ascii);
int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr); int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr);
snd_config_type_t snd_config_get_type(const snd_config_t *config); snd_config_type_t snd_config_get_type(const snd_config_t *config);

View file

@ -2228,6 +2228,38 @@ int snd_config_imake_string(snd_config_t **config, const char *id, const char *v
return 0; return 0;
} }
int snd_config_imake_safe_string(snd_config_t **config, const char *id, const char *value)
{
int err;
snd_config_t *tmp;
char *c;
err = snd_config_make(&tmp, id, SND_CONFIG_TYPE_STRING);
if (err < 0)
return err;
if (value) {
tmp->u.string = strdup(value);
if (!tmp->u.string) {
snd_config_delete(tmp);
return -ENOMEM;
}
for (c = tmp->u.string; *c; c++) {
if (*c == ' ' || *c == '-' || *c == '_' ||
(*c >= '0' && *c <= '9') ||
(*c >= 'a' && *c <= 'z') ||
(*c >= 'A' && *c <= 'Z'))
continue;
*c = '_';
}
} else {
tmp->u.string = NULL;
}
*config = tmp;
return 0;
}
/** /**
* \brief Creates a pointer configuration node with the given initial value. * \brief Creates a pointer configuration node with the given initial value.
* \param[out] config The function puts the handle to the new node at * \param[out] config The function puts the handle to the new node at

View file

@ -57,7 +57,8 @@ USB-Audio.pcm.iec958_device {
"Scarlett 2i4 USB" 999 "Scarlett 2i4 USB" 999
"Sennheiser USB headset" 999 "Sennheiser USB headset" 999
"SWTOR Gaming Headset by Razer" 999 "SWTOR Gaming Headset by Razer" 999
"USB Device 0x46d:0x992" 999 "USB Device 0x46d_0x821" 999
"USB Device 0x46d_0x992" 999
} }
# Second iec958 device number, if any. # Second iec958 device number, if any.

View file

@ -935,7 +935,7 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root,
} }
err = snd_config_get_id(src, &id); err = snd_config_get_id(src, &id);
if (err >= 0) if (err >= 0)
err = snd_config_imake_string(dst, id, err = snd_config_imake_safe_string(dst, id,
snd_ctl_card_info_get_name(info)); snd_ctl_card_info_get_name(info));
__error: __error:
if (ctl) if (ctl)