All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Daniel Mack <zonque@gmail.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org,
	Felix Homann <linuxaudio@showlabor.de>
Subject: Re: Need expert's advice - Fast Track Ultra (8R) dropping samples
Date: Fri, 15 Oct 2010 16:21:41 +0200	[thread overview]
Message-ID: <4CB86375.2050703@ladisch.de> (raw)
In-Reply-To: <20101015085939.GA25380@wok>

Daniel Mack wrote:
> On Fri, Oct 15, 2010 at 09:23:15AM +0200, Clemens Ladisch wrote:
> > Daniel Mack wrote:
> > > > > I have an untested patch ready which should add support for implicit
> > > > > feedback, but I'm uncertain about the condition when to activate this
> > > > > mode.
> > 
> > For UAC2 devices, when the descriptors say so.
> > For UAC1 devices, never (because UAC1 does not have this mode).
> 
> Yes, but UAC1 also doesn't support other things like high speed
> transfers in the specs, still the Linux driver supports it, right?

Mostly with quirks.  Devices marked as UAC1 would not work in Windows
if they required anything not implemented in all more or less current
Windows versions; I don't know if any such device actually exists.

The Linux driver support is a default that is hoped to work with most
quirky devices, to reduce the amount of quirk code.  In the particular
case of UAC1 high speed support, I just added what the Audigy 2 NX
happened to do, because that was the device I had, and the extensions
to UAC1 looked plausible.

> I think we can interpret the ISO endpoint usage bits for this, and if a
> UAC1 device sets them, it should be ok for the Linux driver. Or is there
> any other detail in the spec we could use for judging?

For practical purposes, we cannot start the capture stream without it
being requested by a program when there is more than one possible sample
format/rate for it.

> > >  static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
> > >  {
> > > +		frames = min(capture->frame_count, subs->maxframesize);
> > > +		capture->frame_count -= frames;
> > 
> > This assumes that both streams are running continuously, and you have to
> > make sure to start them at the same time to prevent the frame_count from
> > overflowing or underflowing. 
> 
> The caputure stream must be running continuously, yes. Otherwise, the
> driver can't know how many data it should send.

If the capture stream was started some time before the playback stream,
the counter will be quite huge, and the driver will send lots of
maximum-sized packets, which will eventually overflow the device's
buffer.

If some capture packet gets lost due to an error, the playback stream
will try to compensate for that perceived lower rate.  Since this
protocol does not have sample counters, we cannot work around this; the
best idea probably is to stop the stream (xrun).  It's also possible for
a playback packet to get lost; we cannot do anything about that.

> But the counter can't actually underflow; if there is no more data to
> be sent, the counter will drop to zero, which makes the output stream
> send zero-length packets.

Using a default rate for the initial packets might make more sense.

(The audio output of the TUSB3200 chip will lock up if it gets several
zero-length packets, but that thing is full-speed and adaptive.)

> > In my UA-101 driver, I ensure that the
> > buffer fill level is the same for both streams by submitting each
> > playback packet with the same frame count as the corresponding capture
> > packet; but I'm not sure which algorithm is more robust in practice.
> 
> Yes, I do exactly the same in my proprietary driver for the Native
> Instruments devices, but it seems harder to implement in the generic
> driver. The problem I see with my current approach is that the jitter is
> higher - we now always send the maximum frame size or zero length.

This is called "blocking mode" in FireWire audio, and most FW devices
use it.  There the jitter doesn't matter as much because the packet
frequency is always 8 kHz.

> > > +		/* if this stream is in implicit feedback mode, start the
> > > +		 * capture stream now as the playback stream relies on the
> > > +		 * amount of data we see on the capture IN endpoint.
> > > +		 */
> > > +		if (subs->stream->implicit_feedback && !capture->running) {
> > > +			int ret;
> > > +			capture->ops.retire = retire_paused_capture_urb;
> > 
> > set_interface?
> 
> You mean usb_set_interface()? Why should that be neccessary?

To tell the device that the capture interface is supposed to send data.
Furthermore, any specification-compliant device has a zero-sized
endpoint, or no endpoint at all, in the default alternate setting.


Regards,
Clemens

  parent reply	other threads:[~2010-10-15 14:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-25  9:57 Need expert's advice - Fast Track Ultra (8R) dropping samples Felix Homann
2010-10-01 11:00 ` Felix Homann
2010-10-01 16:29   ` Clemens Ladisch
2010-10-03 11:50     ` Felix Homann
2010-10-03 12:00       ` Daniel Mack
2010-10-05  7:21       ` Clemens Ladisch
2010-10-06 13:57         ` Felix Homann
2010-10-06 14:38           ` Clemens Ladisch
2010-10-06 16:31             ` Felix Homann
2010-10-07  6:37               ` Clemens Ladisch
2010-10-07  8:10                 ` Daniel Mack
2010-10-07  8:50                   ` Felix Homann
2010-10-07 11:35                   ` Felix Homann
2010-10-08  6:26                     ` Clemens Ladisch
2010-10-12  7:18                       ` Daniel Mack
2010-10-12  8:18                         ` Felix Homann
2010-10-12 10:26                           ` Daniel Mack
2010-10-13  7:47                             ` Felix Homann
2010-10-13 12:48                               ` Daniel Mack
2010-10-15  7:23                             ` Clemens Ladisch
2010-10-15  8:59                               ` Daniel Mack
2010-10-15 11:08                                 ` Felix Homann
2010-10-15 14:21                                 ` Clemens Ladisch [this message]
2010-10-03 10:02 ` Daniel Mack

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=4CB86375.2050703@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linuxaudio@showlabor.de \
    --cc=tiwai@suse.de \
    --cc=zonque@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.