From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6130 216.105.38.0/24 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 30B481F463 for ; Tue, 17 Dec 2019 18:44:31 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1ihHpU-0007xJ-Gx; Tue, 17 Dec 2019 18:44:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ihHpS-0007xB-NG for sox-devel@lists.sourceforge.net; Tue, 17 Dec 2019 18:44:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CnPqSX+murJj5eE3aIlnjfzyX3Gwufg5uM6piC5J1kw=; b=V5MEGWqM33jbNhYcwoqEtmcZVB akhhyTRzjzVHLnJgLNYprVXO/G7kV6zXQYKOiLy/C+3pS4WuIjZMj5v+Uz1aPG5xvKIB+fZWUHcdn YwNlcn+26jB7Ccu+9nCPksVXqWestMt0prriYgNGnK/QSrTe77AwgRXmU1yatEYcBBVE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CnPqSX+murJj5eE3aIlnjfzyX3Gwufg5uM6piC5J1kw=; b=XmptMQzqkvl90RP+5YuvDb4z+k c4h56cSZ2/3C1tXXg7Lep48eO/bPh5iiJ8ZmC4u4jkSwuykd/OdD1pb1h1UHy/iuN/jcPgqZNd5aL UhARsWepi2o9gACWMESdksBZY+6yBbtA5b6Z8JWMzNEYsT+XOX75Ia9M/Mh5SNW3dDCg=; Received: from mail-ot1-f48.google.com ([209.85.210.48]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1ihHpQ-003cBy-S1 for sox-devel@lists.sourceforge.net; Tue, 17 Dec 2019 18:44:18 +0000 Received: by mail-ot1-f48.google.com with SMTP id k14so14867235otn.4 for ; Tue, 17 Dec 2019 10:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CnPqSX+murJj5eE3aIlnjfzyX3Gwufg5uM6piC5J1kw=; b=J3uIIuOtzIkWrQIJM1b3v7Wet5xmjDS0m5IAA4wcOR258cDSDmr/vvw9sh9u3v8xK5 5E1cGnKxDA7Yce5Dvqf4D3PM+840XCi5oifs6s6Mhqfm/1s0o3AbClko98KwOaY3XSNP xhjyxNg/kR5PvngrQEWItBikMYuAah/TKLRsw0uv0AHcQtzHNiwKdEoseeuQIANfw4GP Q3V7bOoxkowJsObFwHshrrv2nCHXuSx6+1aFFWALqgmyLxy0367p2F9CwuzSI95xkNCl F7Ngv+R5ENEinSaDbk9WYRU1ZFsvIJ/BzJHk67MHQo2RGYgaNYKjfXGTwA6wWs7oCokN Yemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CnPqSX+murJj5eE3aIlnjfzyX3Gwufg5uM6piC5J1kw=; b=Nunq4LWrJCq4SoTY0ZqgQrR7rAJqpawfK/r1XlYrSb2LaGBR2NYOq3mSmDTcihJOEj efVIYomKwgY9SUyiwmG+sOVysuMljA1DMtsM7QMnZRS2zwuYf6OwR4qa+vXMRecBg1wo 0BkPg80pVFIcP6T1WOMkWDqRr97sJDyfsJa0u723Bnh0+q626gy2a12cOvS2/f+/mRfE c/fZD5JkZzD9hA5GwjNFs+7F72Ks4tS2of+55MbEJnxLeyjkyzXvDfWA9qedVFyJqLro oeaWFu3OikeO7iVi/yKjlkCske4v+Dlu9KSKVuBexzDcBl/ERQwyZt6fIcJkcHeZFYpb Opsg== X-Gm-Message-State: APjAAAXdVZ4jaegCcEAQnkD5s3fBPuJSdUVVJfg6nfaE78Lw/27VcwPK 7eFTI3/hbT3UsQxfzhEDlvepg1uGUhf8BDcLaQe14jym X-Google-Smtp-Source: APXvYqwB2oraZdsqfnitdrc0c2GJVSuuciJ3QAIAWVbZAzb0eT8JFW+ddVgnjWOSEn2IvJnc7RM1KC9lwXipKuHXPOs= X-Received: by 2002:a05:6830:18cd:: with SMTP id v13mr37855405ote.118.1576608250849; Tue, 17 Dec 2019 10:44:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Seth Troisi Date: Tue, 17 Dec 2019 10:43:44 -0800 Message-ID: To: =?UTF-8?B?TcOlbnMgUnVsbGfDpXJk?= X-Headers-End: 1ihHpQ-003cBy-S1 Subject: Re: [Patch] Change to exit(0) for --help-format X-BeenThere: sox-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-devel@lists.sourceforge.net Cc: sox-devel@lists.sourceforge.net Content-Type: multipart/mixed; boundary="===============1083121336751178921==" Errors-To: sox-devel-bounces@lists.sourceforge.net --===============1083121336751178921== Content-Type: multipart/alternative; boundary="000000000000bdef380599eab656" --000000000000bdef380599eab656 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'd be surprised to find someone depending on an exit status that is constant (e.g. if (false) { effectively dead code };) I like the new names in your patch, they are descriptive of what the flag does which is nice. I'm happy with either patch, both of which will satisfies my use case. Thanks for considering. On Tue, Dec 17, 2019 at 4:01 AM M=C3=A5ns Rullg=C3=A5rd wr= ote: > Seth Troisi writes: > > > I'd like to know if the mp3 format is supported from python. > > it's much easier to check an exit code than to grep over stdout for a > string > > I'd rather not change things unnecessarily in case there's someone > relying on the current behaviour. > > How about this instead? > > From 24f71c24ce62d7ea18e5480ab2544b429b652e14 Mon Sep 17 00:00:00 2001 > From: Mans Rullgard > Date: Tue, 17 Dec 2019 12:00:32 +0000 > Subject: [PATCH] add --check-read and --check-write options > > --- > src/sox.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/src/sox.c b/src/sox.c > index 0b103e269092..ffb5d9984f7b 100644 > --- a/src/sox.c > +++ b/src/sox.c > @@ -1941,6 +1941,8 @@ static void usage(char const * message) > "GLOBAL OPTIONS (gopts) (can be specified at any point before the first > effect):", > "--buffer BYTES Set the size of all processing buffers (defaul= t > 8192)", > "--clobber Don't prompt to overwrite output file > (default)", > +"--check-read NAME Check if format NAME can be read", > +"--check-write NAME Check if format NAME can be written", > "--combine concatenate Concatenate all input files (default for sox, > rec)", > "--combine sequence Sequence all input files (default for play)", > "-D, --no-dither Don't dither automatically", > @@ -2146,6 +2148,23 @@ static void usage_format(char const * name) > exit(1); > } > > +static void check_format(const char *fmt, sox_bool write) > +{ > + const sox_format_handler_t *f =3D sox_find_format(fmt, sox_false); > + sox_bool ok =3D sox_false; > + > + if (f) { > + if (write) > + ok =3D f->startwrite || f->write; > + else > + ok =3D f->startread || f->read; > + } > + > + printf("%s %s: %s\n", fmt, write ? "write" : "read", ok ? "yes" : "no"= ); > + > + exit(!ok); > +} > + > static void read_comment_file(sox_comments_t * comments, char const * > const filename) > { > int c; > @@ -2209,6 +2228,8 @@ static struct lsx_option_t const long_options[] =3D= { > {"no-clobber" , lsx_option_arg_none , NULL, 0}, > {"multi-threaded" , lsx_option_arg_none , NULL, 0}, > {"dft-min" , lsx_option_arg_required, NULL, 0}, > + {"check-read" , lsx_option_arg_required, NULL, 0}, > + {"check-write" , lsx_option_arg_required, NULL, 0}, > > {"bits" , lsx_option_arg_required, NULL, 'b'}, > {"channels" , lsx_option_arg_required, NULL, 'c'}, > @@ -2402,6 +2423,8 @@ static char parse_gopts_and_fopts(file_t * f) > } > sox_globals.log2_dft_min_size =3D i; > break; > + case 26: check_format(optstate.arg, sox_false); break; > + case 27: check_format(optstate.arg, sox_true); break; > } > break; > > -- > 2.24.1 > > > > -- > M=C3=A5ns Rullg=C3=A5rd > --000000000000bdef380599eab656 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'd be surprised to find someone depending on an exit = status that is constant (e.g. if (false) { effectively dead code };)
I like the new names in your patch, they are descriptive of what the fla= g does which is nice.
I'm happy with either patch, both= of which will satisfies my use case.

Thanks f= or considering.

On Tue, Dec 17, 2019 at 4:01 AM M=C3=A5ns Rullg=C3=A5r= d <mans@mansr.com> wrote:
Seth Troisi <braintwo@gmail.com&g= t; writes:

> I'd like to know if the mp3 format is supported from python.
> it's much easier to check an exit code than to grep over stdout fo= r a string

I'd rather not change things unnecessarily in case there's someone<= br> relying on the current behaviour.

How about this instead?

>From 24f71c24ce62d7ea18e5480ab2544b429b652e14 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Tue, 17 Dec 2019 12:00:32 +0000
Subject: [PATCH] add --check-read and --check-write options

---
=C2=A0src/sox.c | 23 +++++++++++++++++++++++
=C2=A01 file changed, 23 insertions(+)

diff --git a/src/sox.c b/src/sox.c
index 0b103e269092..ffb5d9984f7b 100644
--- a/src/sox.c
+++ b/src/sox.c
@@ -1941,6 +1941,8 @@ static void usage(char const * message)
=C2=A0"GLOBAL OPTIONS (gopts) (can be specified at any point before th= e first effect):",
=C2=A0"--buffer BYTES=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Set the = size of all processing buffers (default 8192)",
=C2=A0"--clobber=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 Don't prompt to overwrite output file (default)",
+"--check-read NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0 Check if format NAME ca= n be read",
+"--check-write NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0Check if format NAME ca= n be written",
=C2=A0"--combine concatenate=C2=A0 =C2=A0 Concatenate all input files = (default for sox, rec)",
=C2=A0"--combine sequence=C2=A0 =C2=A0 =C2=A0 =C2=A0Sequence all input= files (default for play)",
=C2=A0"-D, --no-dither=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Don't dit= her automatically",
@@ -2146,6 +2148,23 @@ static void usage_format(char const * name)
=C2=A0 =C2=A0exit(1);
=C2=A0}

+static void check_format(const char *fmt, sox_bool write)
+{
+=C2=A0 const sox_format_handler_t *f =3D sox_find_format(fmt, sox_false);<= br> +=C2=A0 sox_bool ok =3D sox_false;
+
+=C2=A0 if (f) {
+=C2=A0 =C2=A0 if (write)
+=C2=A0 =C2=A0 =C2=A0 ok =3D f->startwrite || f->write;
+=C2=A0 =C2=A0 else
+=C2=A0 =C2=A0 =C2=A0 ok =3D f->startread || f->read;
+=C2=A0 }
+
+=C2=A0 printf("%s %s: %s\n", fmt, write ? "write" : &q= uot;read", ok ? "yes" : "no");
+
+=C2=A0 exit(!ok);
+}
+
=C2=A0static void read_comment_file(sox_comments_t * comments, char const *= const filename)
=C2=A0{
=C2=A0 =C2=A0int c;
@@ -2209,6 +2228,8 @@ static struct lsx_option_t const long_options[] =3D {=
=C2=A0 =C2=A0{"no-clobber"=C2=A0 =C2=A0 =C2=A0 , lsx_option_arg_n= one=C2=A0 =C2=A0 , NULL, 0},
=C2=A0 =C2=A0{"multi-threaded"=C2=A0 , lsx_option_arg_none=C2=A0 = =C2=A0 , NULL, 0},
=C2=A0 =C2=A0{"dft-min"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0, lsx_op= tion_arg_required, NULL, 0},
+=C2=A0 {"check-read"=C2=A0 =C2=A0 =C2=A0 , lsx_option_arg_requir= ed, NULL, 0},
+=C2=A0 {"check-write"=C2=A0 =C2=A0 =C2=A0, lsx_option_arg_requir= ed, NULL, 0},

=C2=A0 =C2=A0{"bits"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 , l= sx_option_arg_required, NULL, 'b'},
=C2=A0 =C2=A0{"channels"=C2=A0 =C2=A0 =C2=A0 =C2=A0 , lsx_option_= arg_required, NULL, 'c'},
@@ -2402,6 +2423,8 @@ static char parse_gopts_and_fopts(file_t * f)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sox_globals.log2_dft_min_size =3D i;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
+=C2=A0 =C2=A0 =C2=A0 case 26: check_format(optstate.arg, sox_false); break= ;
+=C2=A0 =C2=A0 =C2=A0 case 27: check_format(optstate.arg, sox_true); break;=
=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0 =C2=A0break;

--
2.24.1



--
M=C3=A5ns Rullg=C3=A5rd
--000000000000bdef380599eab656-- --===============1083121336751178921== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============1083121336751178921== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel --===============1083121336751178921==--