From patchwork Fri Mar 16 10:20:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Wischer X-Patchwork-Id: 10286871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD727601A0 for ; Fri, 16 Mar 2018 10:21:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C98EA28DF5 for ; Fri, 16 Mar 2018 10:21:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBE4F28E0F; Fri, 16 Mar 2018 10:21:07 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE 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 AC53828DF5 for ; Fri, 16 Mar 2018 10:21:06 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7A99226748B; Fri, 16 Mar 2018 11:21:04 +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 16FDB2674CE; Fri, 16 Mar 2018 11:21:02 +0100 (CET) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [62.225.105.245]) by alsa0.perex.cz (Postfix) with ESMTP id 002EF267380 for ; Fri, 16 Mar 2018 11:20:58 +0100 (CET) Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 6D6D33C0BA7; Fri, 16 Mar 2018 11:20:57 +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 tYshvW04xYLU; Fri, 16 Mar 2018 11:20:50 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 924053C09A2; Fri, 16 Mar 2018 11:20:50 +0100 (CET) Received: from vmlxhi-087.adit-jv.com (10.72.93.172) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.382.0; Fri, 16 Mar 2018 11:20:50 +0100 From: To: Date: Fri, 16 Mar 2018 11:20:46 +0100 Message-ID: <1521195646-21615-1-git-send-email-twischer@de.adit-jv.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.72.93.172] Cc: Timo Wischer , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH - IOPLUG 1/1] pcm: ioplug: update prepare and draining state correctly 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 From: Timo Wischer PREPARED should only be set when it is done and it was successfully. DRAINING should be signalled when starting to drain. There is no need to check if draining was successfully because it will change to drop (SETUP) in any case. Signed-off-by: Timo Wischer diff --git a/ChangeLog b/ChangeLog index 22df356..3dff7fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* Set IO plug state to PREPARED after calling the IO plugin prepare callback * update to libtool 1.3.3 0.1.3 -> 0.2.0 diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index af223a1..8c0ed48 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -146,13 +146,16 @@ static int snd_pcm_ioplug_prepare(snd_pcm_t *pcm) ioplug_priv_t *io = pcm->private_data; int err = 0; - io->data->state = SND_PCM_STATE_PREPARED; snd_pcm_ioplug_reset(pcm); if (io->data->callback->prepare) { snd_pcm_unlock(pcm); /* to avoid deadlock */ err = io->data->callback->prepare(io->data); snd_pcm_lock(pcm); } + if (err < 0) + return err; + + io->data->state = SND_PCM_STATE_PREPARED; return err; } @@ -493,6 +496,8 @@ static int snd_pcm_ioplug_drain(snd_pcm_t *pcm) if (io->data->state == SND_PCM_STATE_OPEN) return -EBADFD; + + io->data->state = SND_PCM_STATE_DRAINING; if (io->data->callback->drain) io->data->callback->drain(io->data); snd_pcm_lock(pcm);