From patchwork Thu Nov 17 14:35:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Young X-Patchwork-Id: 9434387 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 1181260469 for ; Thu, 17 Nov 2016 14:55:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 029D9293E0 for ; Thu, 17 Nov 2016 14:55:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB4C629448; Thu, 17 Nov 2016 14:55:22 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no 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 22434293E0 for ; Thu, 17 Nov 2016 14:55:21 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 63AEB267566; Thu, 17 Nov 2016 15:55:20 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AB4AB267563; Thu, 17 Nov 2016 15:52:53 +0100 (CET) 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 D9AAF267556; Thu, 17 Nov 2016 15:36:02 +0100 (CET) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by alsa0.perex.cz (Postfix) with ESMTP id D74D22665B0 for ; Thu, 17 Nov 2016 15:35:56 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id m203so21798303wma.3 for ; Thu, 17 Nov 2016 06:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=19QMuW+0ysJw5v0Klj3j53W+8ICmpPp66wXY1mWUcAU=; b=iukRFj0HnhsnD72oZWYK5CIRPjIrg1BNQNpXWo293YxKIR+dNgWF7IUkibVnyU94hK xsW4i4fuJvTshYElAmoemephsYXY/2YtuG2UkcBvt2NYJYs3eQbDYDBUuRFFSlBjbWgH hN0u2pJCNxcXI90BrvQbEX+rBhAQ4GnK7dHif17AsGQstWxDYWaJxDi59yVZSsSvlK1m snWpi/FB7Iv+mHjiI2Z6WHspRFfUfvVbgiQRdKrIkuB+fUvBCX5a/P97jtxnO9zRJ9Rm e3mKqNFNAYPFFGMNvRh+ZDg0jl3PqiFHot8m4DtTIG994TKPKfaWHU/FXmxgJ1KAvhyS oNYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=19QMuW+0ysJw5v0Klj3j53W+8ICmpPp66wXY1mWUcAU=; b=Q1gR6PvXquGmxTSTaQSVwRnhehA1x9mjX1BZBgyHO72FnrHTWIMKPyQ6EUxA0dI8UV NZTqMZoiKuMEugW9gZfqr3mrDyrWIVBnhNXrTfJ+mF/qqxmtpHaOmm/bwC2Q5N2zY+uy jtaGkPN8WqJWZh5zMqcTCDvOBgW5mXJBHetOJzoMNE1QzwN4nxW66N1A/S8/QHSUZSH8 mPXwcRhhY+NCuTWXBif3OYJQYCTQ85OCJSdnmYfSHqevI0q7YR3/Rn/e5d0VggZI8VtN 8am7ic2roa47ZwCLZtQBQ+Hx7SlLXsksFX5P5pZue+lrCdoFA2lv72djKPJ2phsyVMDe 6+KA== X-Gm-Message-State: ABUngvc7KwC26VIku61Fote4bhiTEcfAAAyk/ZiD3zJtnh2Lx5MlU7kN8AXZVPLc5oKiTw== X-Received: by 10.28.91.143 with SMTP id p137mr17485408wmb.51.1479393356356; Thu, 17 Nov 2016 06:35:56 -0800 (PST) Received: from [192.168.11.11] (178.55.208.46.dyn.plus.net. [46.208.55.178]) by smtp.googlemail.com with ESMTPSA id r138sm15943412wme.9.2016.11.17.06.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 06:35:55 -0800 (PST) To: Takashi Iwai References: <5810BDF9.1020204@IEE.org> <5819F566.2000404@IEE.org> <581A23B9.3050609@IEE.org> <67297312-c4f9-e47d-4b58-893ddb55d2c8@IEE.org> From: Alan Young Message-ID: <8e7fb17d-bf2e-bb4b-8c75-7762f773abe6@IEE.org> Date: Thu, 17 Nov 2016 14:35:55 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Cc: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] [PATCH] pcm_dshare: Do not discard slave reported delay in status result. 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 snd_pcm_dshare_status() gets the underlying status from the slave PCM. This may contain a delay value that includes elements such as codec and other transfer delays. Use this as the base for the returned delay value, adjusted for any frames buffered locally (within the dshare plugin). Note: snd_pcm_dshare_delay() is not updated. Signed-off-by: Alan Young --- src/pcm/pcm_dshare.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) return 0; @@ -207,6 +198,24 @@ static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm) return 0; } +static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm) +{ + snd_pcm_direct_t *dshare = pcm->private_data; + + switch (snd_pcm_state(dshare->spcm)) { + case SND_PCM_STATE_DISCONNECTED: + dshare->state = SNDRV_PCM_STATE_DISCONNECTED; + return -ENODEV; + default: + break; + } + + if (dshare->slowptr) + snd_pcm_hwsync(dshare->spcm); + + return snd_pcm_dshare_sync_ptr0(pcm, *dshare->spcm->hw.ptr); +} + /* * plugin implementation */ @@ -215,22 +224,24 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status) { snd_pcm_direct_t *dshare = pcm->private_data; + memset(status, 0, sizeof(*status)); + snd_pcm_status(dshare->spcm, status); + switch (dshare->state) { case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_RUNNING: - snd_pcm_dshare_sync_ptr(pcm); + snd_pcm_dshare_sync_ptr0(pcm, status->hw_ptr); + status->delay += snd_pcm_mmap_playback_delay(pcm) + + status->avail - dshare->spcm->buffer_size; break; default: break; } - memset(status, 0, sizeof(*status)); - snd_pcm_status(dshare->spcm, status); - status->state = snd_pcm_state(dshare->spcm); + status->trigger_tstamp = dshare->trigger_tstamp; status->avail = snd_pcm_mmap_playback_avail(pcm); status->avail_max = status->avail > dshare->avail_max ? status->avail : dshare->avail_max; dshare->avail_max = 0; - status->delay = snd_pcm_mmap_playback_delay(pcm); return 0; } diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index c5b3178..9b478a7 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -157,23 +157,14 @@ static void snd_pcm_dshare_sync_area(snd_pcm_t *pcm) /* * synchronize hardware pointer (hw_ptr) with ours */ -static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm) +static int snd_pcm_dshare_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr) { snd_pcm_direct_t *dshare = pcm->private_data; - snd_pcm_uframes_t slave_hw_ptr, old_slave_hw_ptr, avail; + snd_pcm_uframes_t old_slave_hw_ptr, avail; snd_pcm_sframes_t diff; - switch (snd_pcm_state(dshare->spcm)) { - case SND_PCM_STATE_DISCONNECTED: - dshare->state = SNDRV_PCM_STATE_DISCONNECTED; - return -ENODEV; - default: - break; - } - if (dshare->slowptr) - snd_pcm_hwsync(dshare->spcm); old_slave_hw_ptr = dshare->slave_hw_ptr; - slave_hw_ptr = dshare->slave_hw_ptr = *dshare->spcm->hw.ptr; + dshare->slave_hw_ptr = slave_hw_ptr; diff = slave_hw_ptr - old_slave_hw_ptr; if (diff == 0) /* fast path */