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 78571C76196 for ; Tue, 11 Apr 2023 13:59:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 407FEF03; Tue, 11 Apr 2023 15:58:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 407FEF03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681221543; bh=G0dbWK9a/t0F69dWz/H6sf/385PZ7uGbJnFAbsDRnG0=; h=Date:From:To:Subject:References:In-Reply-To:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Bjmpa6wQTMMeMiJMwVgqGpGwkpI1yjutODNe4R3n9ZZceUUo5h5A0nA5PneTBvc14 ZA9VEGf4nq1eN2wrBVc65kg5xNP2VzyhWIhuLOdQDy/CsW1py8IiODAMusJGRuw8JY NtsybwsFkw/VpMrQwW1uolUkDUhRHF8ObW04Ntiw= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id EFDBBF8032B; Tue, 11 Apr 2023 15:57:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4BD8F8032B; Tue, 11 Apr 2023 15:57:45 +0200 (CEST) Received: from bluemchen.kde.org (bluemchen.kde.org [IPv6:2001:470:142:8::100]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 30624F80149 for ; Tue, 11 Apr 2023 15:57:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30624F80149 Received: from ugly.fritz.box (localhost [127.0.0.1]) by bluemchen.kde.org (Postfix) with ESMTP id B3E3823EA1; Tue, 11 Apr 2023 09:57:38 -0400 (EDT) Received: by ugly.fritz.box (masqmail 0.3.4, from userid 1000) id 1pmEV8-2cB-00; Tue, 11 Apr 2023 15:57:38 +0200 Date: Tue, 11 Apr 2023 15:57:38 +0200 From: Oswald Buddenhagen To: Jaroslav Kysela Subject: Re: [PATCH 2/2] ALSA: pcm: auto-fill buffer with silence when draining playback Message-ID: Mail-Followup-To: Jaroslav Kysela , alsa-devel@alsa-project.org, Takashi Iwai References: <20230405201219.2197789-1-oswald.buddenhagen@gmx.de> <20230405201219.2197789-2-oswald.buddenhagen@gmx.de> <3d75c103-7e94-e6a1-7f3d-7f957c33cddc@perex.cz> <22f551f3-deae-1536-bd07-0b9340940ea4@perex.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <22f551f3-deae-1536-bd07-0b9340940ea4@perex.cz> Message-ID-Hash: NWFUUAX3UPZ3DR7FSWZX5TT65U4CS34S X-Message-ID-Hash: NWFUUAX3UPZ3DR7FSWZX5TT65U4CS34S X-MailFrom: ossi@kde.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: alsa-devel@alsa-project.org, Takashi Iwai X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, Apr 11, 2023 at 01:09:59PM +0200, Jaroslav Kysela wrote: >On 08. 04. 23 9:24, Oswald Buddenhagen wrote: >>> Also, silencing touches the DMA buffer which may not be desired. >>> >> hypothetically, yes. but practically? [...] > >The buffers can be mmaped so used directly for application and >hardware. > yes, and they are owned by the hardware/driver. an application would know better than doing with them anything they were not designed for. >>> And lastly drivers can handle draining correctly (stop at the exact >>> position - see substream->ops->trigger with SNDRV_PCM_TRIGGER_DRAIN >>> argument). >>> >> yeah. hypothetically. afaict, there is exactly one driver which supports >> this. most (older) hardware wouldn't even have the capability to do such >> precise timing without external help. > >Most hardware has FIFO and most drivers uses the DMA position, so I think that >the interrupt -> stop DMA latency may be covered with this FIFO in most cases. > on most hardware it would be quite a stunt to re-program the buffer pointers on the fly to enable a mid-period interrupt. and given the reliability problems insisted on by takashi in the other thread, the approach seems questionable at best. and that's still ignoring the effort of migrating tens (hundreds?) of drivers. >Again, I would improve the documentation. > no amount of documentation will fix a bad api. it's just not how humans work. >the silencing is controlled using sw_params, so applications may >request the silencing before drain. > yeah, they could, but they don't, and most won't ever. you're arguing for not doing a very practical and simple change that will fix a lot of user code at once, for the sake of preventing an entirely hypothetical and implausible problem. that is not a good trade-off. >Lastly, I think that you cannot call updated snd_pcm_playback_silence() >function with runtime->silence_size == 0. > > if (runtime->silence_size < runtime->boundary) { > you missed the hunk that adjusts the code accordingly. regards