From patchwork Thu Nov 17 15:18:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Young X-Patchwork-Id: 9434449 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 ED3D660238 for ; Thu, 17 Nov 2016 15:51:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC71D29593 for ; Thu, 17 Nov 2016 15:51:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFF06295D4; Thu, 17 Nov 2016 15:51:41 +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 F2F8F29593 for ; Thu, 17 Nov 2016 15:51:40 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 40064267587; Thu, 17 Nov 2016 16:51:39 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 95E33267566; Thu, 17 Nov 2016 16:49:12 +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 C295426756F; Thu, 17 Nov 2016 16:18:56 +0100 (CET) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by alsa0.perex.cz (Postfix) with ESMTP id 0E103266A28 for ; Thu, 17 Nov 2016 16:18:54 +0100 (CET) Received: by mail-wm0-f43.google.com with SMTP id g23so317287942wme.1 for ; Thu, 17 Nov 2016 07:18:54 -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; bh=OozGL75GCFc/oC3MFEh3LlfrQIEIQuGBmvDPEiJll5k=; b=k+iADqlgvTNe8sHuuEtT3ntwldRE8/uNs+a2kOquGpViuL+lQfTHtS6497FqsC50r1 zGgjUTaalpnQLCbAP5sgIvSueHQTLhpNZv2d4LuT7gVdKsg9CuTYDe9uKwwORery0OIm mB3FsAjhQ4h82Lij8N3wkfeXv9iKeOolxtczwld0hN6rj938YsoxVThtzVOCCWjuZprk IObMATOnbQfHySpr+Ssf3AlfhKM0Yh2T4cgzyzME4I954lOH/xcJVmbPzn0ogExOdCih IkcUqbNpbe0ZCerab0nTM0x4GkYbtP1qYC5KqUS43pzi3k8gs22x1Q5rknDq7CETh8Do wK/g== 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; bh=OozGL75GCFc/oC3MFEh3LlfrQIEIQuGBmvDPEiJll5k=; b=mUm9XYpqLrY6o+CMERVDvl5gKckJoLMmxMza+yIjjaP351Lne/4B/5VkJS1ZV9hY9G 5+r3d/BSdiqgaot7azHCw/3Afz3OCJ9Gld6wwewngyD6CJE3zAeiRKZBHdi7P2tYUj3G bp2J42Jd4gmWCT5HUQphhdMWhHxwk2gdEB1fOaPbEDU/qPWWp/3cZHYeFyHXhyj6qm+y +ScPM2OSBKGlbvJTjp+rB3017nLNpCwBd8KdweGrukhYuKQWPJz6hKeb85hrwpQyrVgg C4O7EIncxYmvfLmEvG4YQA6mnJm52LMtx7/R7GNUrzqgazh2lDvBxLFV7Xp+gNdqaKiX Bgzg== X-Gm-Message-State: ABUngvfxtp6aW8X5TZphqJafaZqh5p8nlFcokCmbj8R2ig4wmVm5aTCqDjCV8sESBOMZSA== X-Received: by 10.28.40.67 with SMTP id o64mr16175957wmo.40.1479395934207; Thu, 17 Nov 2016 07:18:54 -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 h2sm3741713wjy.40.2016.11.17.07.18.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 07:18:53 -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> <8e7fb17d-bf2e-bb4b-8c75-7762f773abe6@IEE.org> From: Alan Young Message-ID: Date: Thu, 17 Nov 2016 15:18:53 +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: X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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 On 17/11/16 15:12, Takashi Iwai wrote: > On Thu, 17 Nov 2016 15:35:55 +0100, > Alan Young wrote: >> 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 > Unfortunately, your MUA seems malforming the texts and does > line-break and replacing the tabs, so the patch is broken. > Please either fix your MUA setup or use an attachment as a fallback. Let's try an attachment. From f459991615254066f687ca8d0aef2bdfeff33964 Mon Sep 17 00:00:00 2001 From: Alan Young Date: Wed, 2 Nov 2016 17:40:32 +0000 Subject: [PATCH] pcm_dshare: Do not discard slave reported delay in status result. 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(-) 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 */ 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; } -- 2.5.5