From: Takashi Iwai Subject: Re: [PATCH] ALSA: usb: Work around CM6631 sample rate change bug Date: Mon, 04 Mar 2013 09:53:54 +0100 Message-ID: References: <20130302130403.GD4452@pvv.ntnu.no> <5131FAC1.30007@gmail.com> <20130303192922.GE4452@pvv.ntnu.no> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 1E9B9264F8D for ; Mon, 4 Mar 2013 09:53:55 +0100 (CET) In-Reply-To: <20130303192922.GE4452@pvv.ntnu.no> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Torstein Hegge Cc: alsa-devel@alsa-project.org, Daniel Mack List-Id: alsa-devel@alsa-project.org At Sun, 3 Mar 2013 20:29:22 +0100, Torstein Hegge wrote: > > On Sat, Mar 02, 2013 at 02:12:33PM +0100, Daniel Mack wrote: > > On 02.03.2013 14:04, Torstein Hegge wrote: > > > The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in > > > sampling frequency while the interface is active. > > > > > > Reset the interface after setting the sampling frequency, to ensure that the > > > sample rate set by snd_usb_init_sample_rate() is used. Otherwise, the device > > > will try to use the sample rate of the previous file, causing distorted sound > > > on sample rate changes. > > > > > > Signed-off-by: Torstein Hegge > > > > Acked-by: Daniel Mack > > While this does fix the sample rate change problem, it introduces a new > problem. With at least one media player application (xbmc) this patch > causes the usb sound card to not output sound when starting a video > file. Skipping forward or backward in the video stream restores audio > output. > > I haven't yet been able to look into why this happens, or why xbmc > behaves different from mplayer and vlc. If the reset of interface is needed only when *changing* SRC, we can check the current rate against the previous rate and skip the reset? The difference of xbmc and mplayer/vlc may come from the different initialization procedure. Apps can call hw_params or prepare multiple times, for example, before actually starting the stream. Takashi > > Torstein > > > > --- > > > sound/usb/pcm.c | 10 ++++++++++ > > > 1 file changed, 10 insertions(+) > > > > > > diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c > > > index d82e378..01978a6 100644 > > > --- a/sound/usb/pcm.c > > > +++ b/sound/usb/pcm.c > > > @@ -710,6 +710,16 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) > > > subs->need_setup_ep = false; > > > } > > > > > > + /* Some devices doesn't respond to sample rate changes while the > > > + * interface is active. */ > > > + switch (subs->stream->chip->usb_id) { > > > + case USB_ID(0x0d8c, 0x0304): /* C-Media - Schiit USB Interface */ > > > + case USB_ID(0x0d8c, 0x0309): /* C-Media CM6631 */ > > > + usb_set_interface(subs->dev, subs->cur_audiofmt->iface, > > > + subs->cur_audiofmt->altset_idx); > > > + break; > > > + } > > > + > > > /* some unit conversions in runtime */ > > > subs->data_endpoint->maxframesize = > > > bytes_to_frames(runtime, subs->data_endpoint->maxpacksize); > > > > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >