All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Ben Bell <bjb-alsa-devel@deus.net>
Cc: alsa-devel@alsa-project.org
Subject: Re: Behringer WING usb audio - cyclic xruns dependent on periods/buffers
Date: Fri, 04 Dec 2020 09:04:14 +0100	[thread overview]
Message-ID: <s5hblfa575t.wl-tiwai@suse.de> (raw)
In-Reply-To: <20201203200633.CC66A2C16F@relay2.suse.de>

On Thu, 03 Dec 2020 21:06:24 +0100,
Ben Bell wrote:
> 
> On Sat, Nov 28, 2020 at 09:36:00AM +0000, Ben Bell wrote:
> > > In general you should avoid 44.1kHz if you want a small period size
> > > for a realtime process on USB-audio.  With 44.1kHz, the packet size
> > > can't be fixed in integer, and the ISO transfer requires variable
> > > packet sizes.  OTOH, ALSA API requires the fixed period size, hence
> > > it'll lead to inconsistencies occasionally.
> 
> So changing to 48kHz had no appreciable effect, but I'm working at that
> rate for now to eliminate the 44.1kHz weirdness from investigations.
> Using a USB2 card, also had no effect. Testing with a different USB audio
> interface (albeit a simple stereo one) didn't exhibit the behaviour, even
> when I took buffer sizes right down.
> 
> I'm not sure where to go to get more information or where's the best place
> to ask for help. I'm happy to do the leg work, but I don't know enough
> about the kernel, alsa or USB to figure it out without some help.
> 
> Current question: what is the delay in /proc/asound/card1/pcm0c/sub0/status
> actually measuring? I'm assuming it's measured in samples? I've written
> something to scrape the stats out in a tight loop and report.
> 
> What I see is a cycle where the delay rises and then a chunk equal to the
> frames per period (or sometimes, earlier on fpp-48) is removed. That feels
> like chunks being read out of a buffer. All fine.
> 
> After a while though, the maximum delay we reach with each cycle is creeping
> up. It increases by one every few cycles (usually two or three, or three or
> four -- always oscillating between two values) but of it's still only being
> emptied by a full period's worth of samples each cycle. So the overall effect
> is the delay creeps up and up until it hits the buffer size and then we get
> an xrun.
> 
> Like I said in the initial email, it feels like some sort of clock drift
> problem, where we're managing very slowly to collect more samples than
> we're reading -- to the tune of about 1 extra every few cycles -- and
> nothing on the consumer side is ever managing to compensate for that.
> I'm not even sure how that sort of drift would be possible though. Seems
> surprising.
> 
> Does any of this sound suspicious, or for that matter completely normal?
> Any suggestions where should I be looking next?

At least you can try the latest patch set destined for 5.11, which
should improve the cases for the implicit feedback.

The patches are either in linux-next tree or the
topic/usb-audio-refactoring branch of my sound.git tree.
It's based on 5.10-rc, so should be cleanly mergeable to the latest
Linus tree.


Takashi

  parent reply	other threads:[~2020-12-04  8:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-26 18:06 Behringer WING usb audio - cyclic xruns dependent on periods/buffers Ben Bell
2020-11-27  9:20 ` Takashi Iwai
2020-11-28  9:36   ` Ben Bell
2020-12-03 20:06     ` Ben Bell
     [not found]     ` <20201203200633.CC66A2C16F@relay2.suse.de>
2020-12-04  8:04       ` Takashi Iwai [this message]
2020-12-05 14:43         ` Ben Bell
     [not found]         ` <20201205144406.854292C16C@relay2.suse.de>
2020-12-08 13:30           ` Takashi Iwai
2020-12-09 12:16             ` Ben Bell
     [not found]             ` <20201209121634.8B72A2C1D1@relay2.suse.de>
2020-12-09 12:29               ` 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=s5hblfa575t.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bjb-alsa-devel@deus.net \
    /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.