dapm_new_mixer and 32 bytes limitation
PATCH 1/1 dapm_new_mixer and 32 bytes limitation
Dapm mixer names are truncated to 32 bytes, while alsa control names are 44 bytes wide.
Subsequent usage of functions like snd_ctl_find_id fail because of the mismatch. Unless there's a limitation I don't understand, the following patch fixes the limit back to 44 bytes.
--
Robert
sound/soc/soc-dapm.c +3 -2
@@ -281,7 +281,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, struct snd_soc_dapm_widget *w) {int i, ret =0 ; -char name[32 ]; +char name[44 ];struct snd_soc_dapm_path *path;/* add kcontrol */
@@ -295,7 +295,8 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,continue ;/* add dapm control with long name */ -snprintf (name,32 ,"%s %s" , w->name, w->kcontrols[i].name); +snprintf (name,43 ,"%s %s" , w->name, w->kcontrols[i].name); + name[43 ] =0 ; path->long_name =kstrdup (name,GFP_KERNEL );if (path->long_name ==NULL )return -ENOMEM ;
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At 18 Jan 2008 21:13:36 +0100,
sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 284
Quoted 11 lines · Robert Jarzmik
sound/soc/soc-dapm.c +1
-1@@ -281,7 +281,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, struct snd_soc_dapm_widget *w) {int i, ret =0 ; -char name[32 ]; +char name[44 ];
Let's add a global const in asound.h instead of using a magic number everywhere.
sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 299
Quoted 10 lines
sound/soc/soc-dapm.c +2
-1struct snd_soc_dapm_path *path;/* add kcontrol */ @@ -295,7 +295,8 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,continue ;/* add dapm control with long name */ -snprintf (name,32 ,"%s %s" , w->name, w->kcontrols[i].name); +snprintf (name,43 ,"%s %s" , w->name, w->kcontrols[i].name); + name[43 ] =0 ;
snprintf() terminates the string. The usual call is
snprintf(name, sizeof(name), ...);
Thanks,
Takashi
Jaroslav Kysela
maintainerQuoted 16 lines · Takashi Iwai
At 18 Jan 2008 21:13:36 +0100,
sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 284
Quoted 11 lines · Robert Jarzmik
sound/soc/soc-dapm.c +1
-1@@ -281,7 +281,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, struct snd_soc_dapm_widget *w) {int i, ret =0 ; -char name[32 ]; +char name[44 ];Let's add a global const in
asound.hinstead of using a magic number everywhere.
What about this:
int namelen = sizeof(w->kcontrols[0].name); Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
At Mon, 21 Jan 2008 12:05:55 +0100 (CET),
Quoted 20 lines · Jaroslav Kysela
Quoted 16 lines · Takashi Iwai
At 18 Jan 2008 21:13:36 +0100,
sound/soc/soc-dapm.c static int dapm_new_mixer(struct snd_soc_codec *codec, · line 284
Quoted 11 lines · Robert Jarzmik
sound/soc/soc-dapm.c +1
-1@@ -281,7 +281,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, struct snd_soc_dapm_widget *w) {int i, ret =0 ; -char name[32 ]; +char name[44 ];Let's add a global const in
asound.hinstead of using a magic number everywhere.
Quoted 3 lines
What about this:
int namelen = sizeof(w->kcontrols[0].name);
I thought of it, too, but it's too ugly, I'd say.
Takashi