From patchwork Wed Oct 22 14:14:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Palacios X-Patchwork-Id: 5138241 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DC0719F3ED for ; Thu, 23 Oct 2014 06:16:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B02F2025A for ; Thu, 23 Oct 2014 06:16:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 027DE201F5 for ; Thu, 23 Oct 2014 06:16:34 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EBC9326042E; Thu, 23 Oct 2014 08:16:31 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 988262602AD; Thu, 23 Oct 2014 08:16:21 +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 438A62651E6; Wed, 22 Oct 2014 16:16:01 +0200 (CEST) Received: from mail1.bemta12.messagelabs.com (mail1.bemta12.messagelabs.com [216.82.251.11]) by alsa0.perex.cz (Postfix) with ESMTP id E28112651AF for ; Wed, 22 Oct 2014 16:15:52 +0200 (CEST) Received: from [216.82.249.131:10005] by server-11.bemta-12.messagelabs.com id 55/FB-10662-61CB7445; Wed, 22 Oct 2014 14:15:50 +0000 X-Env-Sender: Hector.Palacios@digi.com X-Msg-Ref: server-14.tower-28.messagelabs.com!1413987348!31591241!2 X-Originating-IP: [66.77.174.13] X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30888 invoked from network); 22 Oct 2014 14:15:50 -0000 Received: from mail.mx3.digi.com (HELO mcl-sms-ns1.digi.com) (66.77.174.13) by server-14.tower-28.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 14:15:50 -0000 Received: from MCL-VMS-XCH01.digi.com (10.5.8.49) by mail.mx1.digi.com (172.16.1.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Wed, 22 Oct 2014 09:15:35 -0500 Received: from DOR-SMS-XCH01.digi.com (10.49.8.99) by MCL-VMS-XCH01.digi.com (10.5.8.49) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 22 Oct 2014 09:15:48 -0500 Received: from log-cln-hpalacio.digi.com (10.101.2.182) by dor-sms-xch01.digi.com (10.49.8.99) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 22 Oct 2014 16:15:45 +0200 From: Hector Palacios To: Date: Wed, 22 Oct 2014 16:14:53 +0200 Message-ID: <1413987293-21544-1-git-send-email-hector.palacios@digi.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.101.2.182] X-KSE-AntiSpam-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean X-Mailman-Approved-At: Thu, 23 Oct 2014 08:16:20 +0200 Cc: hector.palacios@digi.com, broonie@kernel.org Subject: [alsa-devel] [PATCH] ASoC: soc-pcm: always cancel any pending delayed stream shutdown 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 After playback a shutdown is scheduled to happen within 5 seconds. If another playback takes place before the scheduled work times out, the work is cancelled, but if a recording takes place, the work will shutdown in the middle of the recording, causing problems. To reproduce the issue chain the following commands: arecord -M --duration 5 -c 2 /tmp/test.wav; aplay /tmp/test.wav; sleep 2; arecord -M --duration 5 -c 2 /tmp/test.wav; aplay /tmp/test.wav; The fist command records 5 seconds of audio. The second command plays the recorded audio. At the end of the playback a work will be scheduled to shutdown in 5 seconds, but only 2 seconds after the first playback, we run another recording. When we have recorded 3 seconds, the shutdown will occur which can cause incorrect behavior and bad recorded data. As a consequence, the last playback reproduces correct audio for the first 3 seconds and incorrect audio after that. Signed-off-by: Hector Palacios --- sound/soc/soc-pcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 642c86240752..d19a926872e8 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -760,8 +760,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } /* cancel any delayed stream shutdown that is pending */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - rtd->pop_wait) { + if (rtd->pop_wait) { rtd->pop_wait = 0; cancel_delayed_work(&rtd->delayed_work); }