Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: David Henningsson <david.henningsson@canonical.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 1/3] route: Allow chmap syntax for slave channels in ttable
Date: Fri, 21 Feb 2014 16:42:59 +0100	[thread overview]
Message-ID: <s5hwqgotqt8.wl%tiwai@suse.de> (raw)
In-Reply-To: <1392996262-27970-2-git-send-email-david.henningsson@canonical.com>

At Fri, 21 Feb 2014 16:24:20 +0100,
David Henningsson wrote:
> 
> Instead of writing e g "0" and "1", one can now write "FL" and "FR" instead.
> 
> E g:
> 	ttable.0.FL 1
> 	ttable.1.FR 1
> 	ttable.2.LFE 1
> 
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
> ---
>  src/pcm/pcm_route.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
> index 2beedf6..ffc283f 100644
> --- a/src/pcm/pcm_route.c
> +++ b/src/pcm/pcm_route.c
> @@ -789,6 +789,24 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out)
>  	snd_pcm_dump(route->plug.gen.slave, out);
>  }
>  
> +static int safe_chmapchannel(const char *id, long *channel)

You need no safe_ prefix for this function.  safe_strtol() is just
because strtol() already exists in an unsafe way.

Besides that, I find it also OK to just return the channel (>= 0) or a
negative error.  But it's no big matter in which form is.


Takashi

> +{
> +	int err;
> +	int ch;
> +	err = safe_strtol(id, channel);
> +	if (err >= 0)
> +		return err;
> +
> +	ch = (int) snd_pcm_chmap_from_string(id);
> +	if (ch == -1)
> +		return -EINVAL;
> +
> +	/* For now, assume standard channel mapping */
> +	*channel = ch - SND_CHMAP_FL;
> +	return 0;
> +}
> +
> +
>  static const snd_pcm_ops_t snd_pcm_route_ops = {
>  	.close = snd_pcm_route_close,
>  	.info = snd_pcm_generic_info,
> @@ -983,7 +1001,7 @@ int snd_pcm_route_determine_ttable(snd_config_t *tt,
>  			const char *id;
>  			if (snd_config_get_id(jnode, &id) < 0)
>  				continue;
> -			err = safe_strtol(id, &schannel);
> +			err = safe_chmapchannel(id, &schannel);
>  			if (err < 0) {
>  				SNDERR("Invalid slave channel: %s", id);
>  				return -EINVAL;
> @@ -1046,7 +1064,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
>  			const char *id;
>  			if (snd_config_get_id(jnode, &id) < 0)
>  				continue;
> -			err = safe_strtol(id, &schannel);
> +			err = safe_chmapchannel(id, &schannel);
>  			if (err < 0 || 
>  			    schannel < 0 || (unsigned int) schannel > tt_ssize || 
>  			    (schannels > 0 && schannel >= schannels)) {
> -- 
> 1.9.0
> 

  reply	other threads:[~2014-02-21 15:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21 15:24 [PATCH 0/3] alsa-lib - improve surround 2.1 support David Henningsson
2014-02-21 15:24 ` [PATCH 1/3] route: Allow chmap syntax for slave channels in ttable David Henningsson
2014-02-21 15:42   ` Takashi Iwai [this message]
2014-02-21 15:24 ` [PATCH 2/3] route: Select slave chmap based on ttable information David Henningsson
2014-02-21 15:49   ` Takashi Iwai
2014-02-21 15:24 ` [PATCH 3/3] conf: Allow 2.1 surround to use different number of channels David Henningsson
2014-02-21 15:50 ` [PATCH 0/3] alsa-lib - improve surround 2.1 support Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hwqgotqt8.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=david.henningsson@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox