Message ID | s5hmux0brft.wl-tiwai@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 5/15/2018 1:21 PM, Takashi Iwai wrote: > On Mon, 07 May 2018 17:37:44 +0200, > Jay Foster wrote: >> >> >> On 5/4/2018 11:51 PM, Takashi Iwai wrote: >>> On Fri, 04 May 2018 21:57:35 +0200, >>> Jay Foster wrote: >>>> >>>> On 5/4/2018 12:47 PM, Takashi Iwai wrote: >>>>> On Fri, 04 May 2018 19:51:05 +0200, >>>>> Jay Foster wrote: >>>>>> I recently updated may alsa from 1.1.4.1 to 1.1.6. I now noticed that >>>>>> aplay does not work properly (the same as 1.1.4.1) when reading the >>>>>> sound file data from stdin. This might have something to do with the >>>>>> recent change with reading the sound file header. >>>>>> >>>>>> With the previous version of aplay, aplay would report: >>>>>> >>>>>> Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono >>>>>> >>>>>> With 1.1.6, aplay reports: >>>>>> >>>>>> Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono >>>>>> >>>>>> This results in static/noise output. If I explicitly add the '-f >>>>>> S16_LE -r 22050' options to aplay, then it does play correctly. >>>>>> >>>>>> Is this a known bug and is there a fix? >>>>> It works fine on my system. >>>>> >>>>> % aplay test.wav >>>>> Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo >>>>> >>>>> % aplay < ~/test/test.wav >>>>> Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo >>>>> >>>>> % aplay --version >>>>> aplay: version 1.1.6 by Jaroslav Kysela <perex@perex.cz> >>>>> >>>>> >>>>> Takashi >>>>> >>>>> >>>> Well, it does not work for me: >>>> >>>> cat bird-calls.wav | /usr/bin/aplay -Dplughw:0 -- >>>> Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono >>>> ^CAborted by signal Interrupt... >>>> aplay: pcm_write:2051: write error: Interrupted system call >>>> >>>> aplay -Dplughw:0 bird-calls.wav >>>> Playing WAVE 'bird-calls.wav' : Signed 16 bit Little Endian, Rate >>>> 44100 Hz, Stereo >>>> >>>> Looks like aplay may now have problems reading from stdin if stdin is >>>> a pipe. >>> OK, now I see it. It's in the safety check of file stat. >>> The fix patch is below. >>> >> Thanks. That works. > Actually the fix below would be much simpler and better. > I'm going to apply it. > > > Takashi > > -- 8< -- > From: Takashi Iwai <tiwai@suse.de> > Subject: [PATCH] aplay: Fix invalid file size check for non-regular files > > aplay tries to check the file size via fstat() at parsing the format > headers and avoids parsing when the size is shorter than the given > size. This works fine for regular files, but when a special file like > pipe is passed, it fails, eventually leading to the fallback mode > wrongly. > > A proper fix is to do this sanity check only for a regular file. > > Reported-by: Jay Foster <jay@systech.com> > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > aplay/aplay.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/aplay/aplay.c b/aplay/aplay.c > index bbd7fffa04fc..63ec9efbebc1 100644 > --- a/aplay/aplay.c > +++ b/aplay/aplay.c > @@ -2821,7 +2821,8 @@ static int read_header(int *loaded, int header_size) > > /* don't be adventurous, get out if file size is smaller than > * requested header size */ > - if (buf.st_size < header_size) > + if ((buf.st_mode & S_IFMT) == S_IFREG && > + buf.st_size < header_size) > return -1; > > if (*loaded < header_size) { Thanks. Your new patch also works. Jay
diff --git a/aplay/aplay.c b/aplay/aplay.c index bbd7fffa04fc..63ec9efbebc1 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -2821,7 +2821,8 @@ static int read_header(int *loaded, int header_size) /* don't be adventurous, get out if file size is smaller than * requested header size */ - if (buf.st_size < header_size) + if ((buf.st_mode & S_IFMT) == S_IFREG && + buf.st_size < header_size) return -1; if (*loaded < header_size) {