From patchwork Thu Sep 1 02:23:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 9308201 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 49F4860487 for ; Thu, 1 Sep 2016 02:23:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F6E32911C for ; Thu, 1 Sep 2016 02:23:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2414429135; Thu, 1 Sep 2016 02:23:50 +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 5CA522911C for ; Thu, 1 Sep 2016 02:23:48 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EB076266E84; Thu, 1 Sep 2016 04:23:46 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8D396266552; Thu, 1 Sep 2016 04:23:39 +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 CD6B42666DA; Thu, 1 Sep 2016 04:23:37 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id A2B05265750 for ; Thu, 1 Sep 2016 04:23:30 +0200 (CEST) Received: from c83-251-167-59.bredband.comhem.se ([83.251.167.59] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bfHf6-0004VV-60; Thu, 01 Sep 2016 02:23:28 +0000 From: David Henningsson To: tiwai@suse.de, clemens@ladisch.de, alsa-devel@alsa-project.org Date: Thu, 1 Sep 2016 04:23:26 +0200 Message-Id: <1472696606-15309-1-git-send-email-diwic@ubuntu.com> X-Mailer: git-send-email 1.9.1 Cc: David Henningsson Subject: [alsa-devel] [PATCH] test/pcm-multi-thread: Remove pthread_cancel, add snd_pcm_close 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 Because 1) Apparently, our thread cancellation policy is "don't even think about it" and we shouldn't break our own rules 2) It is good practice to close pcm after usage Signed-off-by: David Henningsson --- test/pcm-multi-thread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/pcm-multi-thread.c b/test/pcm-multi-thread.c index da1b87c..26de7db 100644 --- a/test/pcm-multi-thread.c +++ b/test/pcm-multi-thread.c @@ -219,18 +219,22 @@ int main(int argc, char **argv) return 1; } - if (setup_params()) + if (setup_params()) { + snd_pcm_close(pcm); return 1; + } buf = calloc(1, snd_pcm_format_size(format, bufsize) * channels); if (!buf) { fprintf(stderr, "cannot alloc buffer\n"); + snd_pcm_close(pcm); return 1; } for (i = 0; i < num_threads; i++) { if (pthread_create(&peeper_threads[i], NULL, peeper, (void *)(long)i)) { fprintf(stderr, "pthread_create error\n"); + snd_pcm_close(pcm); return 1; } } @@ -255,9 +259,8 @@ int main(int argc, char **argv) running = 0; for (i = 0; i < num_threads; i++) - pthread_cancel(peeper_threads[i]); - for (i = 0; i < num_threads; i++) pthread_join(peeper_threads[i], NULL); + snd_pcm_close(pcm); return 1; }