From: Takashi Iwai Subject: Re: [PATCH v3 1/2] aplay: Show usage if no parameter is passed Date: Tue, 13 Nov 2012 14:35:24 +0100 Message-ID: References: <1352808340-10561-1-git-send-email-fabio.estevam@freescale.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B19E9265140 for ; Tue, 13 Nov 2012 14:35:24 +0100 (CET) In-Reply-To: <1352808340-10561-1-git-send-email-fabio.estevam@freescale.com> 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 To: Fabio Estevam Cc: alsa-devel@alsa-project.org, clemens@ladisch.de List-Id: alsa-devel@alsa-project.org At Tue, 13 Nov 2012 10:05:39 -0200, Fabio Estevam wrote: > > When aplay/arecord are called without any argument the application hangs forever. > > Instead of hanging, print the usage and exit. > > Signed-off-by: Fabio Estevam Applied this one. I suppose there is no v4 for aplay, right? thanks, Takashi > --- > Changes since v2: > - return 1 instead of 0 > - Use stdout for the arecord case > Changes since v1: > - Also check for isatty, so that 'aplay < file.wav' can still work > aplay/aplay.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/aplay/aplay.c b/aplay/aplay.c > index 741979a..66cc78f 100644 > --- a/aplay/aplay.c > +++ b/aplay/aplay.c > @@ -493,6 +493,7 @@ int main(int argc, char *argv[]) > int tmp, err, c; > int do_device_list = 0, do_pcm_list = 0; > snd_pcm_info_t *info; > + FILE *direction; > > #ifdef ENABLE_NLS > setlocale(LC_ALL, ""); > @@ -511,14 +512,21 @@ int main(int argc, char *argv[]) > file_type = FORMAT_WAVE; > command = "arecord"; > start_delay = 1; > + direction = stdout; > } else if (strstr(argv[0], "aplay")) { > stream = SND_PCM_STREAM_PLAYBACK; > command = "aplay"; > + direction = stdin; > } else { > error(_("command should be named either arecord or aplay")); > return 1; > } > > + if (isatty(fileno(direction)) && (argc == 1)) { > + usage(command); > + return 1; > + } > + > chunk_size = -1; > rhwparams.format = DEFAULT_FORMAT; > rhwparams.rate = DEFAULT_SPEED; > -- > 1.7.9.5 > >