diff mbox

[PATCH/alsa-lib] amixer: fix 'cset' operation to set several channels

Message ID 1428287450-3665-1-git-send-email-o-takashi@sakamocchi.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Sakamoto April 6, 2015, 2:30 a.m. UTC
For an enumerated element with several channels, when given comma-separated
string values, 'cset' operation sets these values just to the first channel,
instead of corresponding channels.

This commit adds missing-increment to fix this bug.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 amixer/amixer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Takashi Sakamoto April 6, 2015, 2:33 a.m. UTC | #1
> [PATCH/alsa-lib] amixer: fix 'cset' operation to set several channels

Oops. This patch is for alsa-utils, sorry...

On Apr 06 2015 11:30, Takashi Sakamoto wrote:
> For an enumerated element with several channels, when given comma-separated
> string values, 'cset' operation sets these values just to the first channel,
> instead of corresponding channels.
>
> This commit adds missing-increment to fix this bug.
>
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>   amixer/amixer.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/amixer/amixer.c b/amixer/amixer.c
> index 36c92eb..e9fe735 100644
> --- a/amixer/amixer.c
> +++ b/amixer/amixer.c
> @@ -1290,8 +1290,10 @@ static int sset_enum(snd_mixer_elem_t *elem, unsigned int argc, char **argv)
>   			if (snd_mixer_selem_set_enum_item(elem, item++, ival) >= 0)
>   				check_flag = 1;
>   			/* skip separators */
> -			while (*ptr == ',' || isspace(*ptr))
> +			while (*ptr == ',' || isspace(*ptr)) {
>   				ptr++;
> +				chn++;
> +			}
>   		}
>   	}
>   	return check_flag;
>
Takashi Iwai April 6, 2015, 7:13 a.m. UTC | #2
At Mon,  6 Apr 2015 11:30:50 +0900,
Takashi Sakamoto wrote:
> 
> For an enumerated element with several channels, when given comma-separated
> string values, 'cset' operation sets these values just to the first channel,
> instead of corresponding channels.
> 
> This commit adds missing-increment to fix this bug.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Did you really test this patch...?

amixer.c: In function ‘sset_enum’:
amixer.c:1295:5: error: ‘chn’ undeclared (first use in this function)
	  

Takashi

> ---
>  amixer/amixer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/amixer/amixer.c b/amixer/amixer.c
> index 36c92eb..e9fe735 100644
> --- a/amixer/amixer.c
> +++ b/amixer/amixer.c
> @@ -1290,8 +1290,10 @@ static int sset_enum(snd_mixer_elem_t *elem, unsigned int argc, char **argv)
>  			if (snd_mixer_selem_set_enum_item(elem, item++, ival) >= 0)
>  				check_flag = 1;
>  			/* skip separators */
> -			while (*ptr == ',' || isspace(*ptr))
> +			while (*ptr == ',' || isspace(*ptr)) {
>  				ptr++;
> +				chn++;
> +			}
>  		}
>  	}
>  	return check_flag;
> -- 
> 2.1.0
>
Takashi Sakamoto April 6, 2015, 7:42 a.m. UTC | #3
On Apr 06 2015 16:13, Takashi Iwai wrote:
> At Mon,  6 Apr 2015 11:30:50 +0900,
> Takashi Sakamoto wrote:
>>
>> For an enumerated element with several channels, when given comma-separated
>> string values, 'cset' operation sets these values just to the first channel,
>> instead of corresponding channels.
>>
>> This commit adds missing-increment to fix this bug.
>>
>> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
>
> Did you really test this patch...?
>
> amixer.c: In function ‘sset_enum’:
> amixer.c:1295:5: error: ‘chn’ undeclared (first use in this function)

I workd on 6f9835f. After testing, rebase to current master. Then I 
missed 1a19ec1. I should have compile again in this tree. (missing 
enough caution...)

Well, I think the 1a19ec1 still includes a bug. It cannot parse this 
option correctly.

$ amixer sset enum-element-13,1019 A,B,,D

In this case, no values should be set to the third channel of the 
element. But current implementation set D to the channel and the last 
channel is not changed.

I'll post a new patch, later.


Thanks for your indication.

Takashi Sakamoto
diff mbox

Patch

diff --git a/amixer/amixer.c b/amixer/amixer.c
index 36c92eb..e9fe735 100644
--- a/amixer/amixer.c
+++ b/amixer/amixer.c
@@ -1290,8 +1290,10 @@  static int sset_enum(snd_mixer_elem_t *elem, unsigned int argc, char **argv)
 			if (snd_mixer_selem_set_enum_item(elem, item++, ival) >= 0)
 				check_flag = 1;
 			/* skip separators */
-			while (*ptr == ',' || isspace(*ptr))
+			while (*ptr == ',' || isspace(*ptr)) {
 				ptr++;
+				chn++;
+			}
 		}
 	}
 	return check_flag;