Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Alan Young <Alan.Young@IEE.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] [updated] pcm: rate: Add capability to pass configuration node to plugins
Date: Tue, 21 Feb 2017 13:39:51 +0100	[thread overview]
Message-ID: <s5hr32r67l4.wl-tiwai@suse.de> (raw)
In-Reply-To: <da34dc72-db60-d707-4747-1601123e7f81@IEE.org>

On Tue, 21 Feb 2017 13:02:49 +0100,
Alan Young wrote:
> 
> On 17/02/17 17:59, Takashi Iwai wrote:
> > It becomes too complex by mixing up things in a single loop.
> > Let's take it just simple like:
> >
> > 	if (is_string_array(converter)) {
> > 		snd_config_for_each(i, next, converter) {
> > 			// like the old way
> > 		}
> > 	} else {
> > 		// handle for the new compound type
> > 	}
> 
> 
> Like this?
> 
> 	else if (snd_config_get_type(converter) == SND_CONFIG_TYPE_COMPOUND) {
> 		/*
> 		 * If the convertor compound is an array of alternatives then the id of
> 		 * the first element will be "0" (or maybe NULL). Otherwise assume it is
> 		 * a structure and must have a "name" id to identify the converter type.
> 		 */
> 		snd_config_iterator_t i, next;
> 		i = snd_config_iterator_first(converter);
> 		if (i && i != snd_config_iterator_end(converter)) {
> 			snd_config_t *n = snd_config_iterator_entry(i);
> 			const char *id;
> 			snd_config_get_id(n, &id);
> 			if (!id || strcmp(id, "0") == 0) {

Make this a function, e.g. is_string_array(), as I mentioned.


> 				snd_config_for_each(i, next, converter) {
> 					n = snd_config_iterator_entry(i);
> 					if (snd_config_get_string(n, &type) < 0)
> 						break;
> 					err = rate_open_func(rate, type, NULL, 0);
> 					if (!err)
> 						break;
> 				}

> 			} else {
> 				snd_config_for_each(i, next, converter) {
> 					snd_config_t *n = snd_config_iterator_entry(i);
> 					const char *id;
> 					snd_config_get_id(n, &id);
> 					if (strcmp(id, "name") != 0)
> 						continue;
> 					if (snd_config_get_string(n, &type) < 0)
> 						break;
> 					err = rate_open_func(rate, type, converter, 0);
> 					if (!err)
> 						break;
> 				}

In the second case, calling the open function inside the loop makes
the code unclear.  The loop is only for obtaining the name string.
The open func should be called outside the loop once when you get the
name string (or bail out as an error if no name is found beforehand).


thanks,

Takashi

  reply	other threads:[~2017-02-21 12:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17 15:24 [PATCH] pcm_rate: Do not discard slave reported delay in status result Alan Young
2016-11-17 15:26 ` Alan Young
2016-11-17 16:47 ` Takashi Iwai
2016-11-17 16:51   ` Alan Young
2016-11-17 16:55     ` Takashi Iwai
2016-11-17 17:12 ` [PATCH RESEND] " Alan Young
2016-11-28 19:11   ` Takashi Iwai
2016-12-13 11:43     ` Alan Young
2016-12-13 11:49       ` Takashi Iwai
2016-12-13 13:05         ` Alan Young
2016-12-14 14:29           ` Takashi Iwai
2017-02-08 10:50 ` [PATCH] pcm: rate: Add capability to pass configuration node to plugins Alan Young
2017-02-08 15:36   ` Takashi Iwai
2017-02-09 15:41     ` Alan Young
2017-02-09 15:48       ` Alan Young
2017-02-13 17:20     ` [PATCH] [updated] " Alan Young
2017-02-14  7:08       ` Takashi Iwai
2017-02-14  7:30         ` Alan Young
2017-02-15 12:28           ` Alan Young
2017-02-17 16:53             ` Takashi Iwai
2017-02-17 17:44               ` Alan Young
2017-02-17 17:59                 ` Takashi Iwai
2017-02-21 12:02                   ` Alan Young
2017-02-21 12:39                     ` Takashi Iwai [this message]
2017-02-21 14:34                       ` Alan Young
2017-02-21 14:43                         ` Takashi Iwai
2017-02-21 15:04                           ` Alan Young
2017-02-21 15:14                             ` Takashi Iwai
2017-02-21 15:24                               ` Alan Young
2017-02-21 15:28                                 ` Takashi Iwai
2017-02-21 16:14                                   ` Alan Young
2017-02-21 21:30                                     ` 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=s5hr32r67l4.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=Alan.Young@IEE.org \
    --cc=alsa-devel@alsa-project.org \
    /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