From patchwork Sun Jun 11 14:56:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 9780167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 941806031B for ; Sun, 11 Jun 2017 15:03:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 849E8284B9 for ; Sun, 11 Jun 2017 15:03:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7976D28531; Sun, 11 Jun 2017 15:03:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA2A284B9 for ; Sun, 11 Jun 2017 15:03:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5B2B6266CE8; Sun, 11 Jun 2017 16:56:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3D3E4266CED; Sun, 11 Jun 2017 16:56:26 +0200 (CEST) Received: from smtp-proxy001.phy.lolipop.jp (smtp-proxy001.phy.lolipop.jp [157.7.104.42]) by alsa0.perex.cz (Postfix) with ESMTP id BD78B26696B for ; Sun, 11 Jun 2017 16:56:18 +0200 (CEST) Received: from smtp-proxy001.phy.lolipop.lan (HELO smtp-proxy001.phy.lolipop.jp) (172.19.44.42) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp-proxy001.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Sun, 11 Jun 2017 23:56:16 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp-proxy001.phy.lolipop.jp (LOLIPOP-Fsecure); Sun, 11 Jun 2017 23:56:13 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Date: Sun, 11 Jun 2017 23:56:13 +0900 Message-Id: <20170611145613.24929-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170611145613.24929-1-o-takashi@sakamocchi.jp> References: <20170611145613.24929-1-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 2/2] ALSA: pcm: probe events when parameters are changed actually X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP At present, trace events are probed even if corresponding parameter is not actually changed. This is inconvenient. This commit improves the behaviour. Signed-off-by: Takashi Sakamoto --- sound/core/pcm_native.c | 56 +++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 425f54827e78..5099078dde93 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -278,12 +278,12 @@ static int constrain_mask_params(struct snd_pcm_substream *substream, changed = snd_mask_refine(m, constrs_mask(constrs, k)); if (changed < 0) return changed; - - trace_hw_mask_param(substream, k, 0, &old_mask, m); + if (changed == 0) + continue; /* Set corresponding flag so that the caller gets it. */ - if (changed) - params->cmask |= 1 << k; + trace_hw_mask_param(substream, k, 0, &old_mask, m); + params->cmask |= 1 << k; } return 0; @@ -314,12 +314,12 @@ static int constrain_interval_params(struct snd_pcm_substream *substream, changed = snd_interval_refine(i, constrs_interval(constrs, k)); if (changed < 0) return changed; - - trace_hw_interval_param(substream, k, 0, &old_interval, i); + if (changed == 0) + continue; /* Set corresponding flag so that the caller gets it. */ - if (changed) - params->cmask |= 1 << k; + trace_hw_interval_param(substream, k, 0, &old_interval, i); + params->cmask |= 1 << k; } return 0; @@ -409,29 +409,29 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream, if (changed < 0) return changed; - if (hw_is_mask(r->var)) { - trace_hw_mask_param(substream, r->var, k + 1, - &old_mask, hw_param_mask(params, r->var)); - } - if (hw_is_interval(r->var)) { - trace_hw_interval_param(substream, r->var, k + 1, - &old_interval, hw_param_interval(params, r->var)); - } - - rstamps[k] = stamp; - /* - * When the parameters is changed, notify it to the caller + * When the parameter is changed, notify it to the caller * by corresponding returned bit, then preparing for next * iteration. */ if (changed && r->var >= 0) { + if (hw_is_mask(r->var)) { + trace_hw_mask_param(substream, r->var, + k + 1, &old_mask, + hw_param_mask(params, r->var)); + } + if (hw_is_interval(r->var)) { + trace_hw_interval_param(substream, r->var, + k + 1, &old_interval, + hw_param_interval(params, r->var)); + } + params->cmask |= (1 << r->var); vstamps[r->var] = stamp; again = true; } - stamp++; + rstamps[k] = stamp++; } /* Iterate to evaluate all rules till no parameters are changed. */ @@ -604,7 +604,7 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, const int *v; struct snd_mask old_mask; struct snd_interval old_interval; - int err; + int changed; for (v = vars; *v != -1; v++) { /* Keep old parameter to trace. */ @@ -617,13 +617,15 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, old_interval = *hw_param_interval(params, *v); } if (*v != SNDRV_PCM_HW_PARAM_BUFFER_SIZE) - err = snd_pcm_hw_param_first(pcm, params, *v, NULL); + changed = snd_pcm_hw_param_first(pcm, params, *v, NULL); else - err = snd_pcm_hw_param_last(pcm, params, *v, NULL); - if (snd_BUG_ON(err < 0)) - return err; + changed = snd_pcm_hw_param_last(pcm, params, *v, NULL); + if (snd_BUG_ON(changed < 0)) + return changed; + if (changed == 0) + continue; - /* Trace the parameter. */ + /* Trace the changed parameter. */ if (hw_is_mask(*v)) { trace_hw_mask_param(pcm, *v, 0, &old_mask, hw_param_mask(params, *v));