Skip to contentSkip to conversation

pcm: route: Don't handle no matching chmap as a serious error

PATCH In review Takashi Iwai 2 participants 7 messages Mar 18, 2014 – Mar 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pcm: route: Don't handle no matching chmap as a serious error

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

---
 src/pcm/pcm_route.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
src/pcm/pcm_route.c +1 -3
index ab17fa78be2c..ac11bdc8adfd 100644
@@ -940,10 +940,8 @@ static int find_matching_chmap(snd_pcm_t *spcm, snd_pcm_chmap_t *tt_chmap,
 
 	snd_pcm_free_chmaps(chmaps);
 
-	if (*found_chmap == NULL) {
+	if (*found_chmap == NULL)
 		SNDERR("Found no matching channel map");
-		return -EINVAL;
-	}
 	return 0;
 }
 
Signature · 1 line
1.9.0
#1 lore raw
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Quoted 23 lines
---
 src/pcm/pcm_route.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
src/pcm/pcm_route.c +1 -3
index ab17fa78be2c..ac11bdc8adfd 100644
@@ -940,10 +940,8 @@ static int find_matching_chmap(snd_pcm_t *spcm, snd_pcm_chmap_t *tt_chmap,
 
 	snd_pcm_free_chmaps(chmaps);
 
-	if (*found_chmap == NULL) {
+	if (*found_chmap == NULL)
 		SNDERR("Found no matching channel map");
-		return -EINVAL;
-	}
 	return 0;
 }
 
Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
#2 lore raw

At Tue, 18 Mar 2014 17:19:29 +0100,

Quoted 11 lines · David Henningsson
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

Well, the problem is that PulseAudio doesn't work at all with the current alsa-lib git prior to the commit in some cases. That is, the commit brought some incompatibility.

Quoted 3 lines

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Could you check whether PA 5.0 works as is with alsa-lib git (before the last fix)? It could be seen on some desktop machines.

Takashi

Quoted 31 lines
Quoted 24 lines
---
 src/pcm/pcm_route.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
src/pcm/pcm_route.c +1 -3
index ab17fa78be2c..ac11bdc8adfd 100644
@@ -940,10 +940,8 @@ static int find_matching_chmap(snd_pcm_t *spcm, snd_pcm_chmap_t *tt_chmap,
 
 	snd_pcm_free_chmaps(chmaps);
 
-	if (*found_chmap == NULL) {
+	if (*found_chmap == NULL)
 		SNDERR("Found no matching channel map");
-		return -EINVAL;
-	}
 	return 0;
 }
 
Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
#3 lore raw
Quoted 10 lines · Takashi Iwai

At Tue, 18 Mar 2014 17:19:29 +0100,

Quoted 8 lines · David Henningsson
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Quoted 7 lines
Quoted 3 lines

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

Well, the problem is that PulseAudio doesn't work at all with the current alsa-lib git prior to the commit in some cases. That is, the commit brought some incompatibility.

Hmm, then the error should be somewhere in determine_chmap instead. tt_chmap should be NULL (i e, find_matching_chmap is never called) for using the standard number syntax instead of the new chmap syntax.

What about the patch attached instead (untested) ?

Quoted 6 lines
Quoted 3 lines

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Could you check whether PA 5.0 works as is with alsa-lib git (before the last fix)? It could be seen on some desktop machines.

Let me know if the attached patch works for you. In case it does not I will do this testing later.

Quoted 36 lines

Takashi

Quoted 31 lines
Quoted 24 lines
---
 src/pcm/pcm_route.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
src/pcm/pcm_route.c +1 -3
index ab17fa78be2c..ac11bdc8adfd 100644
@@ -940,10 +940,8 @@ static int find_matching_chmap(snd_pcm_t *spcm, snd_pcm_chmap_t *tt_chmap,
 
 	snd_pcm_free_chmaps(chmaps);
 
-	if (*found_chmap == NULL) {
+	if (*found_chmap == NULL)
 		SNDERR("Found no matching channel map");
-		return -EINVAL;
-	}
 	return 0;
 }
 
Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
Quoted 1 line

From 746358818ead057a32330f7c8510cb65a7059e86 Mon Sep 17 00:00:00 2001

From: David Henningsson <[email protected]>
Date: Tue, 18 Mar 2014 23:07:19 +0100
Subject: [PATCH] route: Return NULL in case of zero found channels in
determine_chmap

This should fix the problem where the old route syntax can no longer be opened.

---
 src/pcm/pcm_route.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
src/pcm/pcm_route.c +4 -1
index ac11bdc..a9097ca 100644
@@ -883,7 +883,10 @@ static int determine_chmap(snd_config_t *tt, snd_pcm_chmap_t **tt_chmap)
 		}
 	}
 
-
+	if (chmap->channels == 0) {
+		free(chmap);
+		chmap = NULL;
+	}
 	*tt_chmap = chmap;
 	return 0;
 
Signature · 1 line
1.7.9.5
#4 lore raw

At Tue, 18 Mar 2014 23:13:02 +0100,

Quoted 30 lines · David Henningsson
Quoted 10 lines · Takashi Iwai

At Tue, 18 Mar 2014 17:19:29 +0100,

Quoted 8 lines · David Henningsson
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Quoted 7 lines
Quoted 3 lines

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

Well, the problem is that PulseAudio doesn't work at all with the current alsa-lib git prior to the commit in some cases. That is, the commit brought some incompatibility.

Hmm, then the error should be somewhere in determine_chmap instead. tt_chmap should be NULL (i e, find_matching_chmap is never called) for using the standard number syntax instead of the new chmap syntax.

What about the patch attached instead (untested) ?

Quoted 4 lines
Quoted 3 lines

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Quoted 5 lines
Quoted 2 lines

Could you check whether PA 5.0 works as is with alsa-lib git (before the last fix)? It could be seen on some desktop machines.

Let me know if the attached patch works for you. In case it does not I will do this testing later.

It seems working, but it revealed another bug, too. I fixed it in git tree, and reverted my last patch along with it.

thanks,

Takashi

#5 lore raw
Quoted 32 lines · Takashi Iwai

At Tue, 18 Mar 2014 23:13:02 +0100,

Quoted 30 lines · David Henningsson
Quoted 10 lines · Takashi Iwai

At Tue, 18 Mar 2014 17:19:29 +0100,

Quoted 8 lines · David Henningsson
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Quoted 7 lines
Quoted 3 lines

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

Well, the problem is that PulseAudio doesn't work at all with the current alsa-lib git prior to the commit in some cases. That is, the commit brought some incompatibility.

Hmm, then the error should be somewhere in determine_chmap instead. tt_chmap should be NULL (i e, find_matching_chmap is never called) for using the standard number syntax instead of the new chmap syntax.

What about the patch attached instead (untested) ?

Quoted 4 lines
Quoted 3 lines

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Could you check whether PA 5.0 works as is with alsa-lib git (before the last fix)? It could be seen on some desktop machines.

Let me know if the attached patch works for you. In case it does not I will do this testing later.

It seems working, but it revealed another bug, too. I fixed it in git tree, and reverted my last patch along with it.

I don't think the patch "route: Fix invalid pointer access" is necessary because determine_chmap is always called before any usage of tt_chmap, and the function always assigns a value to tt_chmap. But it does not hurt either, of course.

Thanks for the testing!

Signature · 2 lines
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
#6 lore raw

At Wed, 19 Mar 2014 13:10:55 +0100,

Quoted 40 lines · David Henningsson
Quoted 38 lines · Takashi Iwai

At Tue, 18 Mar 2014 23:13:02 +0100,

Quoted 35 lines · David Henningsson
Quoted 10 lines · Takashi Iwai

At Tue, 18 Mar 2014 17:19:29 +0100,

Quoted 8 lines · David Henningsson
Quoted 5 lines · Takashi Iwai

When find_matching_chmap() returns an error for the non-matching chmap, the caller, snd_pcm_route_open(), also returns an error although it shouldn't be handled as the fatal error. This results in the probe error with PulseAudio and it gives no real output in the end.

Quoted 7 lines
Quoted 3 lines

Hmm, could you give a more specific example? In case the driver does not support channel maps at all, that case is handled in the beginning of the function.

Well, the problem is that PulseAudio doesn't work at all with the current alsa-lib git prior to the commit in some cases. That is, the commit brought some incompatibility.

Hmm, then the error should be somewhere in determine_chmap instead. tt_chmap should be NULL (i e, find_matching_chmap is never called) for using the standard number syntax instead of the new chmap syntax.

What about the patch attached instead (untested) ?

Quoted 6 lines
Quoted 3 lines

So this only happens if the driver supports channel maps, but only non-compatible with the requested map. In which case I believe it's correct that the probing should fail...?

Could you check whether PA 5.0 works as is with alsa-lib git (before the last fix)? It could be seen on some desktop machines.

Let me know if the attached patch works for you. In case it does not I will do this testing later.

Quoted 6 lines
Quoted 2 lines

It seems working, but it revealed another bug, too. I fixed it in git tree, and reverted my last patch along with it.

I don't think the patch "route: Fix invalid pointer access" is necessary because determine_chmap is always called before any usage of tt_chmap, and the function always assigns a value to tt_chmap.

It crashed in snd_pcm_route_close() before my fix. It called free() with an uninitialized pointer.

Takashi