[alsa-devel] [PATCH] ASoC: dapm: fix prefixed stream name matching in snd_soc_dapm_link_dai_widgets
commit "ASoC: dapm: Modify widget stream name according to prefix" fixed a part of the problem when dai_w->name and w->sname are equal before being prefixed.
Remains the case where w->sname is only a sub string of dai_w->name.
For example, TLV320AIC3x codec defines the widget SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0)
In snd_soc_dapm_link_dai_widgets, we will failed to match "[prefix] Left Playback" with "[prefix] Playback".
Since dai_w and w necessarily belongs to the same dapm when strstr() is called, they necessarily have the same prefix which allow us to compare 'w->sname + prefix_len' with 'dai_w->name + prefix_len' directly without length check.
Signed-off-by: Arnaud Mouiche arnaud.mouiche@invoxia.com --- sound/soc/soc-dapm.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e19a676..7194df4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3392,6 +3392,9 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
/* For each DAI widget... */ list_for_each_entry(dai_w, &card->widgets, list) { + const char *prefix = soc_dapm_prefix(dai_w->dapm); + size_t prefix_len = prefix ? strlen(prefix)+1 : 0; + switch (dai_w->id) { case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_out: @@ -3416,6 +3419,8 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) }
if (!w->sname || !strstr(w->sname, dai_w->name)) + if (!w->sname || + !strstr(w->sname + prefix_len, dai_w->name + prefix_len)) continue;
if (dai_w->id == snd_soc_dapm_dai_in) {
Please, ignore this patch.
it is incorrect (line "if (!w->sname || !strstr(w->sname, dai_w->name))" is not removed)
I will send one again. Arnaud
Le 05/06/2015 15:41, Arnaud Mouiche a écrit :
commit "ASoC: dapm: Modify widget stream name according to prefix" fixed a part of the problem when dai_w->name and w->sname are equal before being prefixed.
Remains the case where w->sname is only a sub string of dai_w->name.
For example, TLV320AIC3x codec defines the widget SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0)
In snd_soc_dapm_link_dai_widgets, we will failed to match "[prefix] Left Playback" with "[prefix] Playback".
Since dai_w and w necessarily belongs to the same dapm when strstr() is called, they necessarily have the same prefix which allow us to compare 'w->sname + prefix_len' with 'dai_w->name + prefix_len' directly without length check.
Signed-off-by: Arnaud Mouiche arnaud.mouiche@invoxia.com
sound/soc/soc-dapm.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e19a676..7194df4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3392,6 +3392,9 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
/* For each DAI widget... */ list_for_each_entry(dai_w, &card->widgets, list) {
const char *prefix = soc_dapm_prefix(dai_w->dapm);
size_t prefix_len = prefix ? strlen(prefix)+1 : 0;
- switch (dai_w->id) { case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_out:
@@ -3416,6 +3419,8 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) }
if (!w->sname || !strstr(w->sname, dai_w->name))
if (!w->sname ||
!strstr(w->sname + prefix_len, dai_w->name + prefix_len)) continue; if (dai_w->id == snd_soc_dapm_dai_in) {
participants (2)
-
Arnaud Mouiche
-
arnaud.mouiche@invoxia.com