From patchwork Thu Jun 12 10:34:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Patrakov X-Patchwork-Id: 4340431 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62353BEEAA for ; Thu, 12 Jun 2014 10:36:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 658902034A for ; Thu, 12 Jun 2014 10:36:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 30DF320328 for ; Thu, 12 Jun 2014 10:35:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id ED2B02657B1; Thu, 12 Jun 2014 12:35:57 +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=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E60BE265767; Thu, 12 Jun 2014 12:34:55 +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 D44A12651B2; Thu, 12 Jun 2014 12:34:53 +0200 (CEST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by alsa0.perex.cz (Postfix) with ESMTP id 821382651B2 for ; Thu, 12 Jun 2014 12:34:47 +0200 (CEST) Received: by mail-la0-f50.google.com with SMTP id b8so565570lan.23 for ; Thu, 12 Jun 2014 03:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MKP3UM/zrNf6AjatPtOERLn20CuTUt3JIEFLq4aYSaE=; b=CX9PQQNpGELefXB9HAXbmwss+8RI9pEB01WVyCSoLQ0yy3zJjdlq9lCNL2pAP0KMm8 NJAG1BXZT0HFf+dj89YQCHJLyXrZ5rTZbUKegtd+ZWbqQeqaMWdQjeCpNYAwg53tV6h6 MIXLjlDqxlMH74UsvjWukBWNn/nL0KzggZ/IBju8l0XoJasM2yt3fiV/bjkUtIFY4rqv ilURFvyUsPwEF36+t3keYZglTE1MwfXUh0LS2q7dzYCwZ4lUa0vDwzWLgrBAjimW11Na l2S87yBjySOB+FEg46Rkxu7Vx1PTU1Jz0TEITOCZynO2FmXp06Dz7Wy83ZpP6JQnUFpl vVzA== X-Received: by 10.112.156.199 with SMTP id wg7mr6996163lbb.1.1402569286135; Thu, 12 Jun 2014 03:34:46 -0700 (PDT) Received: from localhost.localdomain (111279190.convex.ru. [82.193.153.141]) by mx.google.com with ESMTPSA id b6sm24054791laa.20.2014.06.12.03.34.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jun 2014 03:34:45 -0700 (PDT) From: "Alexander E. Patrakov" To: alsa-devel@alsa-project.org Date: Thu, 12 Jun 2014 16:34:23 +0600 Message-Id: <1402569264-2789-4-git-send-email-patrakov@gmail.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1402569264-2789-1-git-send-email-patrakov@gmail.com> References: <1402569264-2789-1-git-send-email-patrakov@gmail.com> Cc: "Alexander E. Patrakov" Subject: [alsa-devel] [PATCH 3/4] pcm: multi: implement rewindable and forwardable callbacks 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 Signed-off-by: Alexander E. Patrakov --- src/pcm/pcm_multi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index f58852c..a84e0ce 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -555,6 +555,42 @@ static int snd_pcm_multi_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *in return err; } +static snd_pcm_sframes_t snd_pcm_multi_rewindable(snd_pcm_t *pcm) +{ + snd_pcm_multi_t *multi = pcm->private_data; + unsigned int i; + snd_pcm_sframes_t frames = LONG_MAX; + + for (i = 0; i < multi->slaves_count; ++i) { + snd_pcm_sframes_t f = snd_pcm_rewindable(multi->slaves[i].pcm); + if (f <= 0) + return f; + if (f < frames) + frames = f; + } + + return frames; + +} + +static snd_pcm_sframes_t snd_pcm_multi_forwardable(snd_pcm_t *pcm) +{ + snd_pcm_multi_t *multi = pcm->private_data; + unsigned int i; + snd_pcm_sframes_t frames = LONG_MAX; + + for (i = 0; i < multi->slaves_count; ++i) { + snd_pcm_sframes_t f = snd_pcm_forwardable(multi->slaves[i].pcm); + if (f <= 0) + return f; + if (f < frames) + frames = f; + } + + return frames; + +} + static snd_pcm_sframes_t snd_pcm_multi_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames) { snd_pcm_multi_t *multi = pcm->private_data; @@ -932,7 +968,9 @@ static const snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = { .writen = snd_pcm_mmap_writen, .readi = snd_pcm_mmap_readi, .readn = snd_pcm_mmap_readn, + .rewindable = snd_pcm_multi_rewindable, .rewind = snd_pcm_multi_rewind, + .forwardable = snd_pcm_multi_forwardable, .forward = snd_pcm_multi_forward, .resume = snd_pcm_multi_resume, .link = snd_pcm_multi_link,