From patchwork Sun May 17 18:22:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: GitHub issues - opened X-Patchwork-Id: 192681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB454C433DF for ; Sun, 17 May 2020 18:23:36 +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 2624720709 for ; Sun, 17 May 2020 18:23:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="d63fDRew" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2624720709 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 6CF16165E; Sun, 17 May 2020 20:22:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6CF16165E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1589739814; bh=tOH5hp4QtknWuhuM1Ja0FPAQLhIkAubfRAwYBalus2k=; h=From:To:In-Reply-To:References:Subject:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d63fDRew3gY1Akc+PqA06uoJmtbHuZf+TT9plJllpESf8jEZLuElnpGW3c0xAL232 vqgbvxXJj6xerBeEhmSl9ijICk1NnB3bgWJSV+T6ETB23Uv3hKWkHVoarTFqmSOgom pLoVvoMuY/HVKBW2WJTX23x9hkcH0k/ltLzDcxrc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D801AF80161; Sun, 17 May 2020 20:22:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7361FF801A3; Sun, 17 May 2020 20:22:41 +0200 (CEST) Received: from webhooks-bot.alsa-project.org (gate.perex.cz [77.48.224.242]) by alsa1.perex.cz (Postfix) with ESMTP id 931FDF8015C for ; Sun, 17 May 2020 20:22:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 931FDF8015C MIME-Version: 1.0 From: GitHub issues - edited To: alsa-devel@alsa-project.org In-Reply-To: <1589739754381473064-webhooks-bot@alsa-project.org> References: <1589739754381473064-webhooks-bot@alsa-project.org> Subject: no audio when using the dshare plugin with ALSA driver using indirect PCM data transfer Message-Id: <20200517182241.7361FF801A3@alsa1.perex.cz> Date: Sun, 17 May 2020 20:22:41 +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; }