From patchwork Fri Jun 13 06:58:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey X-Patchwork-Id: 4347321 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 2C8289F314 for ; Fri, 13 Jun 2014 06:59:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 535D820254 for ; Fri, 13 Jun 2014 06:59:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id AC7D4201B9 for ; Fri, 13 Jun 2014 06:59:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 86F8926171B; Fri, 13 Jun 2014 08:59:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,FROM_EXCESS_BASE64,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 6008E26171D; Fri, 13 Jun 2014 08:58:57 +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 8E9A3261721; Fri, 13 Jun 2014 08:58:56 +0200 (CEST) Received: from f39.i.mail.ru (f39.i.mail.ru [94.100.178.227]) by alsa0.perex.cz (Postfix) with ESMTP id AB68326171D for ; Fri, 13 Jun 2014 08:58:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=References:In-Reply-To:Content-Transfer-Encoding:Content-Type:Message-ID:Reply-To:Date:Mime-Version:Subject:To:From; bh=OYlPqlgVvPWFLR10mcmDJgTdxkf+YeS6PJaw4RfiUTA=; b=BXEyl39pRdoD/vLCN3+WogFFM+do4kUx6ny92Zyc6bx878JfG3szr3n9Htb7BEh47Zjz1Yl5keHiEEtPg16el9I14WOTV/Z27VhXm25zd4uVS5BWSybWGDAlLdIzuUDw9I/MsrNWKpd3xDRGdDL9tlZNXgEPRMvBIe+2vFfenfQ=; Received: from mail by f39.i.mail.ru with local (envelope-from ) id 1WvLRn-0005zH-4v for alsa-devel@alsa-project.org; Fri, 13 Jun 2014 10:58:47 +0400 Received: from [85.198.167.125] by e.mail.ru with HTTP; Fri, 13 Jun 2014 10:58:47 +0400 From: =?UTF-8?B?U2VyZ2V5?= To: =?UTF-8?B?YWxzYS1kZXZlbA==?= Mime-Version: 1.0 X-Mailer: Mail.Ru Mailer 1.0 X-Originating-IP: [85.198.167.125] Date: Fri, 13 Jun 2014 10:58:47 +0400 X-Priority: 3 (Normal) Message-ID: <1402642727.109608901@f39.i.mail.ru> X-Mras: Ok X-Spam: undefined In-Reply-To: <1402642371.496174944@f39.i.mail.ru> References: <1402642371.496174944@f39.i.mail.ru> Subject: [alsa-devel] =?utf-8?q?=5BPATCH_1/2=5D_pcm=3A_break_out_of_snd=5F?= =?utf-8?q?pcm=5Fwrite=5Fareas=28=29_if_write_function_returned_0?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: =?UTF-8?B?U2VyZ2V5?= 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 When pcm is stuck and write func returns 0, snd_pcm_write_areas() loops infinitely freezing the application and not allowing it to handle the case. Can be reproduced with: # aplay -vvv /dev/zero pcm.!default { type plug slave.pcm { type null } slave.format S32_LE } This patch fixes it by breaking the loop if func returns 0. Note: pcm_null stuckness must be fixed on its own. --- src/pcm/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 7e46014..5bb7582 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -6816,7 +6816,7 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area if (! frames) break; err = func(pcm, areas, offset, frames); - if (err < 0) + if (err <= 0) break; frames = err; if (state == SND_PCM_STATE_PREPARED) {