From patchwork Thu Oct 15 10:57:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricard Wanderlof X-Patchwork-Id: 7404841 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9AB79F1D5 for ; Thu, 15 Oct 2015 10:58:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C792020553 for ; Thu, 15 Oct 2015 10:57:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B89542085C for ; Thu, 15 Oct 2015 10:57:57 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1EA092665C9; Thu, 15 Oct 2015 12:57:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C83BB260462; Thu, 15 Oct 2015 12:57:48 +0200 (CEST) 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 007E8265338; Thu, 15 Oct 2015 12:57:46 +0200 (CEST) Received: from bes.se.axis.com (bes.se.axis.com [195.60.68.10]) by alsa0.perex.cz (Postfix) with ESMTP id 171F1260453 for ; Thu, 15 Oct 2015 12:57:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id B96712E456; Thu, 15 Oct 2015 12:57:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id IUShp53nzLSK; Thu, 15 Oct 2015 12:57:39 +0200 (CEST) Received: from boulder.se.axis.com (boulder.se.axis.com [10.0.2.104]) by bes.se.axis.com (Postfix) with ESMTP id 14CDF2E07C; Thu, 15 Oct 2015 12:57:39 +0200 (CEST) Received: from boulder.se.axis.com (localhost [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 064C71390; Thu, 15 Oct 2015 12:57:38 +0200 (CEST) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by boulder.se.axis.com (Postfix) with ESMTP id DD3B5135F; Thu, 15 Oct 2015 12:57:38 +0200 (CEST) Received: from lnxricardw1.se.axis.com (lnxricardw1.se.axis.com [10.88.7.2]) by thoth.se.axis.com (Postfix) with ESMTP id D6D803404D; Thu, 15 Oct 2015 12:57:38 +0200 (CEST) Received: by lnxricardw1.se.axis.com (Postfix, from userid 9470) id D4A6E54080; Thu, 15 Oct 2015 12:57:38 +0200 (CEST) From: Ricard Wanderlof To: alsa-devel Date: Thu, 15 Oct 2015 12:57:32 +0200 Message-Id: <1444906657-16791-3-git-send-email-ricardw@axis.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1444906657-16791-1-git-send-email-ricardw@axis.com> References: <1444906657-16791-1-git-send-email-ricardw@axis.com> Cc: Takashi Iwai , Ricard Wanderlof , Ricard Wanderlof Subject: [alsa-devel] [PATCH 2/7] ALSA: USB-audio: Also move out hwptr_done wrap from prepare_playback_urb() 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Refactoring in preparation for adding Zoom R16 quirk. Signed-off-by: Ricard Wanderlof --- sound/usb/pcm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 4292bad..ee8dd9e 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1383,6 +1383,8 @@ static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs, subs->hwptr_done++; } } + if (subs->hwptr_done >= runtime->buffer_size * stride) + subs->hwptr_done -= runtime->buffer_size * stride; } static void copy_to_urb(struct snd_usb_substream *subs, @@ -1403,6 +1405,8 @@ static void copy_to_urb(struct snd_usb_substream *subs, runtime->dma_area + subs->hwptr_done, bytes); } subs->hwptr_done += bytes; + if (subs->hwptr_done >= runtime->buffer_size * stride) + subs->hwptr_done -= runtime->buffer_size * stride; } static void prepare_playback_urb(struct snd_usb_substream *subs, @@ -1480,14 +1484,13 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, } subs->hwptr_done += bytes; + if (subs->hwptr_done >= runtime->buffer_size * stride) + subs->hwptr_done -= runtime->buffer_size * stride; } else { /* usual PCM */ copy_to_urb(subs, urb, stride, bytes); } - if (subs->hwptr_done >= runtime->buffer_size * stride) - subs->hwptr_done -= runtime->buffer_size * stride; - /* update delay with exact number of samples queued */ runtime->delay = subs->last_delay; runtime->delay += frames;