Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1549854ima; Thu, 25 Oct 2018 00:37:57 -0700 (PDT) X-Google-Smtp-Source: AJdET5fMyoS4p9BgdU7z4P8xPbra4Tauza2P/zJn9u0PJiBfJAn5yviPtlY5RwEF32Q73mNtrnX4 X-Received: by 2002:a17:902:70c3:: with SMTP id l3-v6mr471753plt.125.1540453077671; Thu, 25 Oct 2018 00:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540453077; cv=none; d=google.com; s=arc-20160816; b=ehzmJXWr5bC98Kto4MPSTP6LnlQDETdlCfZGWVngc8U27MxrVhpfvf795apeFF1tec k73RY2wuhhmCp2qco/d3rC86R2eXMUVyFnHBRW7XLfcrYjGvZxpS0jGCLQr7L5QvBfQr nqOVdWtiTAwZyT8NFrLwN4VuyvvnOpjhBnZT1qLH0SVW2V3wcxP4DGxIQY7bjO2Kc/fT 56s6S0gPeGBPGhREM1PvZfpA/qIW/meNxvH+LBJpDx6AWHJXuviZzbwtxQJFhdrFEdMw TLJjM+2NKUwn2u1DO5z+qPp7sy1Diii7eIu7TS9VBGtW36xH6fqHWQ5jskvyrFurAHc8 eIXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date; bh=OPyGOH+iri7H1sv9HRXgw/S2S4m+P8dnoLSQXYWMhrw=; b=z7pUVkn7qhQG8oPnsyEg7vBVTItlXl272KVzEd67bXLBoy3jMxLFCQRKBpgfu70g+Z 6KLmk6WOynTTMayTm0Nbuy1UK7n2s5sX7iv8TvGihw4G8evIljs2EhsPPHiYoaPf4xVH u3ozsBvWk6ou3B+PUMFpbjNL1vEx1bq82FFa1vbFR1VCOkBASRIsq3Wed7XUN/g0AYDt wwCZXeEgxa906yJiWOsnTMzQ148SXILHjSdf29juV74GgXB/7PVVn5G862S7vtViKNt6 0iIuSlJHuRtT0VPvtWducUFI3Ek8fl/5YiU0Mp16W+lU2kPj0SBI7j2ecNXGRtQQ7FEK pSzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1-v6si6960223pgm.328.2018.10.25.00.37.40; Thu, 25 Oct 2018 00:37:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbeJYQIv (ORCPT + 99 others); Thu, 25 Oct 2018 12:08:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:57228 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726471AbeJYQIv (ORCPT ); Thu, 25 Oct 2018 12:08:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C9D44AF63; Thu, 25 Oct 2018 07:37:18 +0000 (UTC) Date: Thu, 25 Oct 2018 09:37:15 +0200 Message-ID: From: Takashi Iwai To: Kirill Marinushkin Cc: Mike Brady , stefan.wahren@i2se.com, devel@driverdev.osuosl.org, alsa-devel@alsa-project.org, f.fainelli@gmail.com, eric@anholt.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, linux-rpi-kernel@lists.infradead.org, nishka.dasgupta_ug18@ashoka.edu.in, linux-arm-kernel@lists.infradead.org Subject: Re: [alsa-devel] [PATCH v2] staging: bcm2835-audio: interpolate audio delay In-Reply-To: <9884c4f5-2343-e3a4-8d8b-dd2db404ef27@gmail.com> References: <20181022191708.GA4659@ubuntu> <046aea96-e0d3-60f4-c61a-c26bb1b5c193@gmail.com> <9884c4f5-2343-e3a4-8d8b-dd2db404ef27@gmail.com> 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/26 (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=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 25 Oct 2018 00:02:34 +0200, Kirill Marinushkin wrote: > > >> When you play sound - the pointer increments. > > > > Unfortunately, when you play sound, the pointer does not actually increment, for up to about 10 milliseconds. I know of no way to actually access the true “live” position of the frame that is being played at any instant; hence the desire to estimate it. > > > > Your vision of situation in the opposite from my vision. What you see as a > symptom - I see as a root cause. As I see, you should fix the > pointer-not-incrementing. Why do you think that it's okay that the pointer is > not updating during sound play? Why do you insist that there is a delay? I don't > understand why we are so stuck here. Well, in the API POV, it's nothing wrong to keep hwptr sticking while updating only delay value. It implies that the hardware chip doesn't provide the hwptr update. Though, usually the delay value is provided also from the hardware, e.g. reading the link position or such. It's a typical case like USB-audio, where the hwptr gets updated and the delay indicates the actual position *behind* hwptr. That works because hwptr shows the position in the ring buffer at which you can access the data. And it doesn't mean that hwptr is the actually playing position, but it can be ahead of the current position, when many samples are queued on FIFO. The delay is provided to correct the position back to the actual point. But, this also doesn't mean that the delay shouldn't be used for the purpose like this patchset, either. OTOH, providing a finer hwptr value would be likely more apps-friendly; there must be many programs that don't evaluate the delay value properly. So, I suppose that hwptr update might be a better option if the code won't become too complex. Let's see. One another thing I'd like to point out is that the value given in the patch is nothing but an estimated position, optimistically calculated via the system timer. Mike and I had already discussion in another thread, and another possible option would be to provide the proper timestamp-vs-hwptr pair, instead of updating the timestamp always at the status read. Maybe it's worth to have a module option to suppress this optimistic hwptr update behavior, in case something went wrong with clocks? thanks, Takashi