Subject: Re: A strage problem with stdio.
To: Koh Sato <k-sato@ks-s.otaru-uc.ac.jp>
From: Todd Vierling <tv@wasabisystems.com>
List: netbsd-help
Date: 12/22/2000 12:16:31
On Thu, 21 Dec 2000, Koh Sato wrote:

:     It works fine when I converted an MP3 file into a WAV file
: (in a disk, utilizing madplay) and then play the WAV file
: with 'waveplay'.  But when I connected madplay and waveplay
: via pipe, it failed.

[via pipe]
: 0000000    R   I   F   F  \0  \0  \0  \0   W   A   V   E   f   m   t

[to file]
: 0000000    R   I   F   F   $   l  \0  \0   W   A   V   E   f   m   t

A WAV file (or more generally, any RIFF file) has a chunk _size_ at bytes
4-7, which you can see above.  When madplay writes a WAV file, it's probably
expecting to calculate the size of the file and lseek() back to the
beginning to overwrite those 4 bytes with the actual size.  Since a pipe is
not seekable, it's not able to do such writing.

You may want to try mpg123, not madplay, as I have successfully done piping
with mpg123 in the past.  I can't remember if I used WAV file output, but I
did some pipe manipulation on the data....

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --  http://www.wasabisystems.com/