From patchwork Tue Nov 6 12:48:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Wischer X-Patchwork-Id: 10670281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9D7215E9 for ; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E7B729289 for ; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FC9E29281; Tue, 6 Nov 2018 12:48:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SUBJ_OBFU_PUNCT_FEW autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E0BD29289 for ; Tue, 6 Nov 2018 12:48:27 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E741A2679F7; Tue, 6 Nov 2018 13:48:23 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E185F267A7B; Tue, 6 Nov 2018 13:48:20 +0100 (CET) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by alsa0.perex.cz (Postfix) with ESMTP id ECB6E2678F2 for ; Tue, 6 Nov 2018 13:48:16 +0100 (CET) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 4E9183C003F; Tue, 6 Nov 2018 13:48:15 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X1ea_78byBrb; Tue, 6 Nov 2018 13:48:09 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id DC6443C02ED; Tue, 6 Nov 2018 13:48:08 +0100 (CET) Received: from [10.72.93.172] (10.72.93.172) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Nov 2018 13:48:08 +0100 To: Takashi Iwai From: Timo Wischer Message-ID: Date: Tue, 6 Nov 2018 13:48:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.72.93.172] Cc: Laxmi Devi , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH - dmix v3 0/1] pcm: dmix: Align slave_hw_ptr to slave period boundary X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On 10/30/18 14:21, Takashi Iwai wrote: > Yes, and is this correct?  Suppose you start a stream at the position > one sample before the next period (psize * N + (psize-1)). Then > slave_hw_ptr is psize * N.  At the next moment, the dpcm->hw.ptr > reaches to psize * (N+1), and snd_pcm_dmix_sync_ptr() gets called. > Then slave_hw_ptr will be updated to psize * (N+1) although only one > sample has been processed? I have created a spreadsheet to simulate the behavior of dmix (see attachment). I used this sheet to test different corner cases with different implementations. Column B-D describes 3 corner cases with the original implementation. Column E-H describes the corner cases with patch v2 applied and column I-L describes the corner cases with patch v3. With patch v3 I was not able to find a corner case which would fail. All our internal audio test are also passing fine. The corner cases are described in the form N*period+period-1 (N+1)period+1 (N+2)period+1 The first line describes the value of dmix->spcm->hw.ptr when snd_pcm_dmix_start() will be called. The second line describes the hw_ptr when poll() returns for the first time and the third line describes the hw_ptr when poll() returns for the second time. In column B is the issue case described when the patch is not applied. snd_pcm_avail() returns 2 frames only (B27) but the buffer only contains 3 frames (B18). Therefore up to 5 frames are available (a buffer size of 8 frames is choosen). The issue case of patch v2 is shown in column H. snd_pcm_avail() returns 7 frames (H46) but the buffer contains still 3 frames (H37). Therefore there are only 5 frames free to overwrite. Do you see any corner cases which I missed or any other drawbacks? Best regards and thanks for your time Timo