From patchwork Sun May 17 15:44:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: GitHub pull_request - opened X-Patchwork-Id: 11554179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 018E7739 for ; Sun, 17 May 2020 15:45:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 041C32070A for ; Sun, 17 May 2020 15:45:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="lk5jWRgp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 041C32070A Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=alsa-project.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AFED91672; Sun, 17 May 2020 17:44:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AFED91672 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1589730319; bh=BzxrJSXN73kjuujkKZKTwobTsLSIi3r9e8FXxzrgmTo=; h=From:To:In-Reply-To:References:Subject:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lk5jWRgpBS7xBHeXl2IUPNrMbIzELBLpwlYRgtBo4JmhXc/9KNKPtG/Vx0l6TUyz0 kKnJwH7GRUBIumjNNf1mGlRHDE2VQX+UEmQAzxuk7GEtiWqF5StU6qGbpsIEL+KJP/ 661AmZ1JmcTxqlcT/dTfCEAEx7lZPo2zlsWt/lgU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 03371F80161; Sun, 17 May 2020 17:44:33 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id EA875F800E3; Sun, 17 May 2020 17:44:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=MISSING_DATE,MISSING_MID, SPF_FAIL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from webhooks-bot.alsa-project.org (gate.perex.cz [77.48.224.242]) by alsa1.perex.cz (Postfix) with ESMTP id E1D20F800E3 for ; Sun, 17 May 2020 17:44:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E1D20F800E3 MIME-Version: 1.0 From: GitHub issues - edited To: alsa-devel@alsa-project.org In-Reply-To: <1589730260290796995-webhooks-bot@alsa-project.org> References: <1589730260290796995-webhooks-bot@alsa-project.org> Subject: no audio when using the dshare plugin with ALSA driver using indirect PCM data transfer Message-Id: <20200517154426.EA875F800E3@alsa1.perex.cz> Date: Sun, 17 May 2020 17:44:26 +0200 (CEST) X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" alsa-project/alsa-lib issue #51 was edited from bondagit: Hi all, I am currently working on an open source project on GitHub [AES67 Linux daemon with WebUI](https://github.com/bondagit/aes67-linux-daemon). This project uses the [Merging Technologies ALSA RAVENNA/AES67 Linux Driver](https://bitbucket.org/MergingTechnologies/ravenna-alsa-lkm/src/master). This ALSA driver does support the mmap access using indirect PCM data transfer. The driver is working properly when used directly but not when it's used via the **dshare** plugin. See issue [No sound using dshare in asound.conf](https://github.com/bondagit/aes67-linux-daemon/issues/7) in the AES67 Linux daemon project. For all my tests I used the **Linux Kernel 5.3.0-51** and the **alsa-lib v1.1.9** but I get same results with most recent kernel and with the **alsa-lib** on the master branch. My _.asoundrc_ configuration is the following: ``` pcm.aes67 { type hw card 1 device 0 #sync_ptr_ioctl true } pcm_slave.nforce { pcm "aes67" channels 2 rate 48000 buffer_size 24576 period_size 48 format S24_3LE periods 0 period_time 1000 } pcm.ch12 { type dshare ipc_key 47110815 slave nforce bindings.0 0 bindings.1 1 #slowptr true } ``` Basically when I playback a sample PCM audio using the ALSA RAVENNA/AES67 HW device directly via mmap I get a proper playout. Ex: `aplay -D hw:1 sample.raw -M` But if I do the same using the dshare plugin I do always get no audio (silence): Ex: `aplay -D ch12 sample.raw -M` After a number of tests trying to compare the behavior of the **alsa-lib** when using the ALSA driver directly (aplay -D hw:1) and when using the plugin (aplay -D ch12) I realized that in the second case the **SNDRV_PCM_IOCTL_SYNC_PTR ioctl** is never triggered in the audio loop by the **alsa-lib** . (I could easily capture this by using strace). I would expect the `snd_pcm_dshare_mmap_commit() `function of **alsa-lib** to invoke the above ioctl but this is not happening. The result is that in the ALSA driver the **ack()** callback is not called to indicate that the **appl_ptr** is updated and this causes the problem we have. In the Linux kernel when the ioctl SNDRV_PCM_IOCTL_SYNC_PTR is called the following functions are called: `snd_pcm_sync_ptr() -> pcm_lib_apply_appl_ptr() -> substream->ops->ack() ` but as stated above this is happening only if the ALSA driver is used directly (aplay -D hw:1) and not when it's used via the plugin (aplay -D ch12). I could fix the issue applying the following temporary fix to the `alsa-lib`: ``` ``` The fix basically triggers the call to the `snd_pcm_hw_mmap_commit()` function of the slave pcm of the dshare plugin. This function invokes the ` issue_applptr() ` and then the `sync_ptr1()` that finally calls the SNDRV_PCM_IOCTL_SYNC_PTR ioctl to update the **appl_ptr** in the kernel. After applying this fix I can properly hear the audio. I am available to provide any additional information and to do additional tests. Since I don't have much experience with the `alsa-lib` it can be that the problem is related to some misconfiguration but at present I managed to solve the issue only by applying the above fix. Thanks in advance for your help. Issue URL : https://github.com/alsa-project/alsa-lib/issues/51 Repository URL: https://github.com/alsa-project/alsa-lib diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index f135b5df..1f103414 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -562,6 +562,7 @@ static snd_pcm_sframes_t snd_pcm_dshare_mmap_commit(snd_pcm_t *pcm, /* clear timer queue to avoid a bogus return from poll */ if (snd_pcm_mmap_playback_avail(pcm) < pcm->avail_min) snd_pcm_direct_clear_timer_queue(dshare); + dshare->spcm->fast_ops->mmap_commit(dshare->spcm, offset, size); } return size; }