Josh Coalson
2004-Sep-10 16:45 UTC
[Flac-dev] Re: [Flac-dev]: flac and pipes problems (was: Possible bug)
> A minor point. Would it not be better if flac defaulted to .wav input > rather than raw samples. I think it's going to get wav input an order > of > magnitude more than raw samples? It saves always having to put the > -fw in > there, on these: > > $ flac -fw - mj.flac < mj.wav > $ cat mj.wav | flac -fw - mj.flac > > For that matter it should be able to detect wav input and fall back > to raw > samples if not detected? The chances of a raw file starting: > > RIFFxxxxWAVEfmt > > Are not worth caring about.This is an old thread, but I have implemented a crude form of autodetection that should be sufficient. Basically, since the case we really care about is pipe input and ungetc only guarantees you 4 characters, it just checks for 'RIFF'. This should be enough since the usage clearly states that only WAVE files and raw are supported. Josh __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/
Christian Weisgerber
2004-Sep-10 16:45 UTC
[Flac-dev] Re: [Flac-dev]: flac and pipes problems (was: Possible bug)
Josh Coalson <xflac@yahoo.com> wrote:> autodetection that should be sufficient. Basically, since the > case we really care about is pipe input and ungetc only guarantees > you 4 characters, it just checks for 'RIFF'.^ Where is that figure from? Per POSIX and SUSv2 _one_ character of push-back is guaranteed. -- Christian "naddy" Weisgerber naddy@mips.inka.de
> > autodetection that should be sufficient. Basically, since the > > case we really care about is pipe input and ungetc only guarantees > > you 4 characters, it just checks for 'RIFF'. > ^ > Where is that figure from? Per POSIX and SUSv2 _one_ character of > push-back is guaranteed. >eeewww, yes, it looks like you are correct. so I bit the bullet and did autodetect the correct way. now it will read the first 12 bytes of the file and check for RIFFxxxxWAVE. and instead of ungetc()ing it, I changed the wav and raw readers to use up the lookahead first. not trivial when you consider pipes and --skip, but it had to be done. even though this didn't make it into 0.10, ungetc seems to handle 4 calls on every platform I tested on (glibc, msvc, solaris). Josh __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/