From patchwork Wed May 31 10:49:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9756627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EE6E60360 for ; Wed, 31 May 2017 10:49:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 624A720855 for ; Wed, 31 May 2017 10:49:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 570EA283C9; Wed, 31 May 2017 10:49:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9740720855 for ; Wed, 31 May 2017 10:49:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B12A0266AA1; Wed, 31 May 2017 12:49:50 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5825C266B63; Wed, 31 May 2017 12:49:49 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 70C9F266991 for ; Wed, 31 May 2017 12:49:45 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A25D3ACED; Wed, 31 May 2017 10:49:44 +0000 (UTC) Date: Wed, 31 May 2017 12:49:44 +0200 Message-ID: From: Takashi Iwai To: Cheng Sun In-Reply-To: References: 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.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] [PATCH] dmix: fix inconsistent status X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 30 May 2017 17:33:08 +0200, Takashi Iwai wrote: > > On Fri, 26 May 2017 11:45:53 +0200, > Cheng Sun wrote: > > > > Hi all, > > > > Following on from my previous email with subject "1.1.3 bug report: > > dmix reports inconsistent status", this is a preliminary patch which > > fixes the issue. > > > > Comments are welcome. In particular note that I'm not very familiar > > with this code, and in particular I still don't quite understand what > > the original commit which introduced this bug (38a2d2e) is meant to be > > doing. > > > > Note also that if this patch is committable, based on the commit > > comment for 38a2d2e I think there might be an analogous change to be > > made to faf53c1. > > Can it be simply like the patch below? I came to believing this is the right way to go. Below is the proper patch. If this works for you, I'm going to apply. thanks, Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] pcm: dmix: Fix the inconsistent PCM state The commit 38a2d2eda880 ("pcm: dmix: Do not discard slave reported delay in...") changed the handling in snd_pcm_dmix_status() for taking the actual delay from the slave PCM status. Along with it, the commit removed the line to update its own state altogether, as it had been done originally in the dshare patch (commit faf53c197cab "pcm_dshare: Do not discard slave reported delay..."), supposing that the slave PCM keeps this same state. However, for dmix/dshare, the PCM state may differ from the slave, thus these changes resulted in the inconsistent PCM state. For dshare, the issue was already addressed by commit ad6957c61867 ("plugin:dshare: wrong state reporting"), while the fix for dmix was forgotten until now. This patch restores the code to set the proper dmix PCM state again like in the previous versions. Fixes: 38a2d2eda880 ("pcm: dmix: Do not discard slave reported delay in...") Reported-by: Cheng Sun Signed-off-by: Takashi Iwai --- src/pcm/pcm_dmix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index c64ae5fc21f9..a6a8f3a84678 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -501,6 +501,7 @@ static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status) break; } + status->state = snd_pcm_dmix_state(pcm); status->trigger_tstamp = dmix->trigger_tstamp; status->avail = snd_pcm_mmap_playback_avail(pcm); status->avail_max = status->avail > dmix->avail_max ? status->avail : dmix->avail_max;