From patchwork Sun May 17 15:27:18 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: 192682 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.8 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, URIBL_BLOCKED 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 1BEC0C433E0 for ; Sun, 17 May 2020 15:28:13 +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 9CF3D207BB for ; Sun, 17 May 2020 15:28:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="JxxISk/8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CF3D207BB 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 CD1F31676; Sun, 17 May 2020 17:27:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CD1F31676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1589729290; bh=T+UngzXS4i3hcfZyjq5S9AeHtozg1cq3YZZIjxxCTdc=; h=From:To:In-Reply-To:References:Subject:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JxxISk/8nRr5FUddgM9SBzphh0+th3wZCkF0aSAIHQvI9dTiM8agX34x8Wn6WM4cf hNsvky7ecgH5FH1gdCSYhaSl9OG1zyYZBuKajoeU/7mA11WTuMEC7f75xJbkynMqwF wpRS0hVkzjcwEomHR6+AdwqBp8b8/heGPxVE9tEM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 57088F800C9; Sun, 17 May 2020 17:27:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85CE6F801A3; Sun, 17 May 2020 17:27:18 +0200 (CEST) Received: from webhooks-bot.alsa-project.org (gate.perex.cz [77.48.224.242]) by alsa1.perex.cz (Postfix) with ESMTP id B2422F800C9 for ; Sun, 17 May 2020 17:27:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2422F800C9 MIME-Version: 1.0 From: GitHub issues - edited To: alsa-devel@alsa-project.org In-Reply-To: <1589729231742917061-webhooks-bot@alsa-project.org> References: <1589729231742917061-webhooks-bot@alsa-project.org> Subject: no audio when using the dshare plugin with ALSA driver using indirect PCM data transfer Message-Id: <20200517152718.85CE6F801A3@alsa1.perex.cz> Date: Sun, 17 May 2020 17:27:18 +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. 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 mydshare 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 mydshare) 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 mydshare). 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; }