From patchwork Tue Nov 13 06:41:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10679941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0636C18F0 for ; Tue, 13 Nov 2018 07:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E831C29647 for ; Tue, 13 Nov 2018 07:37:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC0E22A47A; Tue, 13 Nov 2018 07:37:24 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 D7A792A478 for ; Tue, 13 Nov 2018 07:37:22 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B2D64267B8D; Tue, 13 Nov 2018 07:42:52 +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 4902F267B6B; Tue, 13 Nov 2018 07:42:48 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by alsa0.perex.cz (Postfix) with ESMTP id E6745267B58 for ; Tue, 13 Nov 2018 07:42:31 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id u3-v6so2866601pfm.4 for ; Mon, 12 Nov 2018 22:42:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TYH9g4Rtu6TzDE0yUbXA5vQN4cpqtZDA9Vn11BhpHi0=; b=fyw19BabTUmjwXxHUg57jKVZKbmYT2EXKWJxJ7IdovtcvQXKeaiPw+Gw6XWnpEs2SJ On1Baqlpe6xBuoUro8QH/A5o3oAnru7LeQtqaJf/QcjYSFU1w1FcpHYMyOGhwHQQE/j3 UZ4skx+BaclX6grtfUgNoL0ZSV5v6hqfFl+uCiM5QTC5H+YK+ZqAydHpMERQ4sp1TYa1 6FnNixoYgytxrnq5EgkUWZ8iim85q0BI08PyQ3iC/NO8Q8VlJZRYjVZmoOjpivE6fS9c zLTjJYGbeCTLoMp5IWMNS+4BuyHkpZWCxNTXQvut9p5A95ykRgcnE+fO1RaYr0Nco2TF aLFA== X-Gm-Message-State: AGRZ1gJgB9dd9fhasiRDNwvGxRksfCaspYeRvXRLFEKZvhbQgxphTKlJ wTiJSTBsQnBslh8F9cEmcYv32F2S X-Google-Smtp-Source: AJdET5fvTod9TT/EBVbWyeLhJcQFvOIjTSUnhFK8opfmASo6DoCVeYfqpA4wBRr+oLvcQ9zr1yu0Dw== X-Received: by 2002:a62:7893:: with SMTP id t141-v6mr3907996pfc.259.1542091350314; Mon, 12 Nov 2018 22:42:30 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:acf1:2274:aafd:ab4c]) by smtp.gmail.com with ESMTPSA id h7sm11207634pfa.105.2018.11.12.22.42.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 22:42:29 -0800 (PST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Date: Tue, 13 Nov 2018 15:41:33 +0900 Message-Id: <20181113064147.13577-21-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181113064147.13577-1-o-takashi@sakamocchi.jp> References: <20181113062459.DD8F7267A5C@alsa0.perex.cz> <20181113064147.13577-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 21/35] axfer: add an option to finish transmission at XRUN 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 In aplay, '--fatal-errors' option has an effect to give up recovery of PCM substream from XRUN state. This commit adds support for this option. In original implementation, this option brings program abort. This seems to generate core dump of process VMA. However, typically, XRUN comes from timing mismatch between hardware and application, therefore core dump has less helpful. This commit finishes this program in usual way with this option at XRUN. Signed-off-by: Takashi Sakamoto --- axfer/xfer-libasound.c | 11 ++++++++++- axfer/xfer-libasound.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/axfer/xfer-libasound.c b/axfer/xfer-libasound.c index 60e9aab..77c142e 100644 --- a/axfer/xfer-libasound.c +++ b/axfer/xfer-libasound.c @@ -9,9 +9,16 @@ #include "xfer-libasound.h" #include "misc.h" +enum no_short_opts { + // 200 or later belong to non us-ascii character set. + OPT_FATAL_ERRORS = 200, +}; + #define S_OPTS "D:" static const struct option l_opts[] = { {"device", 1, 0, 'D'}, + // For debugging. + {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, }; static int xfer_libasound_init(struct xfer_context *xfer, @@ -39,6 +46,8 @@ static int xfer_libasound_parse_opt(struct xfer_context *xfer, int key, if (key == 'D') state->node_literal = arg_duplicate_string(optarg, &err); + else if (key == OPT_FATAL_ERRORS) + state->finish_at_xrun = true; else err = -ENXIO; @@ -305,7 +314,7 @@ static int xfer_libasound_process_frames(struct xfer_context *xfer, if (err < 0) { if (err == -EAGAIN) return err; - if (err == -EPIPE) { + if (err == -EPIPE && !state->finish_at_xrun) { // Recover the stream and continue processing // immediately. In this program -EPIPE comes from // libasound implementation instead of file I/O. diff --git a/axfer/xfer-libasound.h b/axfer/xfer-libasound.h index 3f3ae6e..270288d 100644 --- a/axfer/xfer-libasound.h +++ b/axfer/xfer-libasound.h @@ -29,6 +29,8 @@ struct libasound_state { bool verbose; char *node_literal; + + bool finish_at_xrun:1; }; // For internal use in 'libasound' module.