From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7781C4361A for ; Fri, 4 Dec 2020 08:05:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCA9E22573 for ; Fri, 4 Dec 2020 08:05:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCA9E22573 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4B58D1843; Fri, 4 Dec 2020 09:04:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4B58D1843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1607069114; bh=asl2mza81WavtwIQZwDewQGhcoU2z/BAQXXvuzXQoTQ=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gC89EzHgcHE8P3b8zH2i5v5QrOKr6Z7JKfoNFVnwFYz6WGb0JlaKqXTJ6NkeZ9u6I WnOITdyj2hoI09k+ZXW28GoLteALccOjFXSP2E7xlEiyrp+M0XL54VQckhg0undgPS d+4gL01Dn1EpYVSbtWKuU43CVS+TfDi91xJTvMh8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BD645F80273; Fri, 4 Dec 2020 09:04:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 594CFF80278; Fri, 4 Dec 2020 09:04:21 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 145D7F8012A for ; Fri, 4 Dec 2020 09:04:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 145D7F8012A X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D43CDAD41; Fri, 4 Dec 2020 08:04:15 +0000 (UTC) Date: Fri, 04 Dec 2020 09:04:14 +0100 Message-ID: From: Takashi Iwai To: Ben Bell Subject: Re: Behringer WING usb audio - cyclic xruns dependent on periods/buffers In-Reply-To: <20201203200633.CC66A2C16F@relay2.suse.de> References: <20201126180612.E3E0CF80166@alsa1.perex.cz> <20201128093612.48C0CF80166@alsa1.perex.cz> <20201203200633.CC66A2C16F@relay2.suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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