mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiada Wang <jiada_wang@mentor.com>
To: <perex@perex.cz>, <tiwai@suse.com>, <o-takashi@sakamocchi.jp>,
	<clemens@ladisch.de>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	<jiada_wang@mentor.com>, <apape@de.adit-jv.com>
Subject: [PATCH 2/2] ALSA: usb-audio: avoid setting of sample rate multiple times on bus
Date: Tue, 6 Dec 2016 14:46:15 +0900	[thread overview]
Message-ID: <20161206054615.29187-3-jiada_wang@mentor.com> (raw)
In-Reply-To: <20161206054615.29187-1-jiada_wang@mentor.com>

From: Daniel Girnus <dgirnus@de.adit-jv.com>

Some of userland applications call 'snd_pcm_hw_params()' and
'snd_pcm_hw_prepare()' sequentially, which means 'snd_pcm_hw_prepare()'
is called twice and the second 'snd_pcm_hw_prepare()' is called in
'SNDRV_PCM_STATE_PREPARED' state.

Some devices are not able to manage this and they will stop playback
if the sample rate will be configured several times over USB protocol.

V2: updated Changelog

Signed-off-by: Daniel Girnus <dgirnus@de.adit-jv.com>
Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
 sound/usb/pcm.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 44d178e..a522c9a 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -806,17 +806,18 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto unlock;
 
-	iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
-	alts = &iface->altsetting[subs->cur_audiofmt->altset_idx];
-	ret = snd_usb_init_sample_rate(subs->stream->chip,
-				       subs->cur_audiofmt->iface,
-				       alts,
-				       subs->cur_audiofmt,
-				       subs->cur_rate);
-	if (ret < 0)
-		goto unlock;
-
 	if (subs->need_setup_ep) {
+
+		iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
+		alts = &iface->altsetting[subs->cur_audiofmt->altset_idx];
+		ret = snd_usb_init_sample_rate(subs->stream->chip,
+					       subs->cur_audiofmt->iface,
+					       alts,
+					       subs->cur_audiofmt,
+					       subs->cur_rate);
+		if (ret < 0)
+			goto unlock;
+
 		ret = configure_endpoint(subs);
 		if (ret < 0)
 			goto unlock;
-- 
2.9.3

  parent reply	other threads:[~2016-12-06  5:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06  5:46 [PATCH 0/2 v2] usb-audio misc fix Jiada Wang
2016-12-06  5:46 ` [PATCH v2 1/2] ALSA: usb-audio: more tolerant packetsize Jiada Wang
2016-12-06  7:13   ` Takashi Iwai
2016-12-06 12:11   ` [alsa-devel] " Clemens Ladisch
2016-12-06  5:46 ` Jiada Wang [this message]
2016-12-06 15:02 ` [PATCH 0/2 v2] usb-audio misc fix 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=20161206054615.29187-3-jiada_wang@mentor.com \
    --to=jiada_wang@mentor.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=apape@de.adit-jv.com \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®