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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B7117C4321E for ; Mon, 5 Dec 2022 12:35:01 +0000 (UTC) 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 1C91217BC; Mon, 5 Dec 2022 13:34:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1C91217BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1670243696; bh=xJu7gLlv3xOkTpPFXmCYBEAqkzNXrMLvovCXwWF2uYc=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RkQEi+M2m60LlhztoLU+jSdP+UI1kwkWPJ2AHbClsbUCWq2WSs6O7fh59hWyLW9XF +pmuO61koVGBQw9MLpQ+MezaqHc/IYtr/56kZAYI3DJYA3p0j5/EBKbEy68h4ysUkF frZGxo65eakOswYEoyiyv4Y8mAGzEp13SrNBTd/Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C2EE9F80171; Mon, 5 Dec 2022 13:34:05 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AF29FF80236; Mon, 5 Dec 2022 13:34:04 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5EA58F80171 for ; Mon, 5 Dec 2022 13:33:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5EA58F80171 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HoxE511v"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Ry0BIGFg" Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AB5B321ED4; Mon, 5 Dec 2022 12:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1670243637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nAZJCt+50yyltjgSuIpUZSQMZGD9Y/4Avwa0UPwoVBA=; b=HoxE511vu3dDAgLsByyk0Xqb6Ujjq0Z0vJQNS1oeIWo2A2Thxn0zatRLBUj7tQXzw9PkPh 9AvfPcK3PCFElehH0RZshGN/9tp3hd6B3HaO4Bkx5LioyTamS/t9fOQlHSY8X9TUFfpnp3 5kyEdygX4bx6AlRdFK0SFK621szygBc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1670243637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nAZJCt+50yyltjgSuIpUZSQMZGD9Y/4Avwa0UPwoVBA=; b=Ry0BIGFgLNetbUfJuobTpPxxLT+YRnl7DK+42IoauqiIves1ujCKOT1VSnIbSFXIeyAeqm 8f92DL+NA7KVLbDQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 8D1D51348F; Mon, 5 Dec 2022 12:33:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id GY+HITXljWOpUAAAGKfGzw (envelope-from ); Mon, 05 Dec 2022 12:33:57 +0000 Date: Mon, 05 Dec 2022 13:33:56 +0100 Message-ID: <87lenmm3m3.wl-tiwai@suse.de> From: Takashi Iwai To: Carl Hetherington Subject: Re: Query about xrun on usb/pcm In-Reply-To: <656d9d2-a0ec-7a3-394c-7a84b17afa11@carlh.net> References: <87y1s3v4ba.wl-tiwai@suse.de> <87edtv6pi6.wl-tiwai@suse.de> <87fse2qk51.wl-tiwai@suse.de> <18aa8f93-92c7-eea-101f-8982292b6e18@carlh.net> <87cz93o9ab.wl-tiwai@suse.de> <656d9d2-a0ec-7a3-394c-7a84b17afa11@carlh.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") 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 Mon, 05 Dec 2022 12:59:54 +0100, Carl Hetherington wrote: > > Hi Takashi, > > > > Can you see any problems with that? In the application code I do need > > > to re-try the snd_pcm_prepare() if one fails with -EPIPE, but with this > > > undo step the second snd_pcm_prepare() is able to recover the endpoint > > > states, instead of hitting this problem where it tries to start things > > > that are STOPPING, but also won't set things to STOPPED because > > > stop_operating is false. > > > > Setting the stop_operating unconditionally there doesn't look right, > > as there may be other error types not only the pending XRUN. > > > > The problem is rather specific to USB audio driver that tries to start > > the stream at PCM prepare, so it's better to handle in USB audio > > driver itself. That is, when -EPIPE is returned from > > start_endpoints() at prepare, the driver does some action. > > > > I can see two options: > > - Issue snd_pcm_stop_xrun() when start_endpoints() returns -EPIPE > > - Repeat the prepare after the sync at snd_usb_pcm_prepare() > > > > The former would require a bit of change in snd_pcm_stop_xrun(), and > > it relies on the application retrying the prepare. The latter would > > be more self-contained. I attached two patches (totally untested) for > > both scenarios. > > > > My gut feeling is for the latter solution, but this needs > > verification. > > The latter solution seems to fix our problem perfectly! Thank you so > much! > > Is there anything I can/should do to help get the change merged? I'm going to submit fix patches and put you to Cc. I believe that the former patches are also valid, although it doesn't influence in your case, so they'll be included. The fixes will be likely included in 6.2-rc1. thanks, Takashi