On Thu, Jul 29, 2010 at 10:57:42PM +0100, Ximin Luo wrote: >> Looks like this or libsndfile is broken, I'll now investigate closer, >> just wanted to share the workaround with you. >> >> If you like, confirm if it's working for you. > Yup, this works, thanks :)
[..] > Just out of interest, is this considered a broken flac file or not? If No, it's valid: http://flac.sourceforge.net/format.html#metadata_block_streaminfo See <36>: "A value of zero here means the number of total samples is unknown." > so, maybe I should file a bug with the GNOME sound recorder people too? It is a bug in libsndfile, I'm therefore reassigning this bug to libsndfile and CC the maintainer who happens to also be the upstream author. ;) Erik, for further information and test files, see this bug report. Everything else is mentioned in the patch. ;) Cheerio -- mail: a...@thur.de http://adi.thur.de PGP/GPG: key via keyserver
From: Adrian Knoth <a...@drcomp.erfurt.thur.de> Bug-Debian: http://bugs.debian.org/590752 Description: Correctly open/read FLAC streams of unknown length Some FLAC files provide a zero sample count, because they are live streams or dumps of such a live recorder. If so, don't simply return zero samples, but treat the stream almost like a pipe and wait for EOF. --- a/src/flac.c +++ b/src/flac.c @@ -342,6 +342,10 @@ sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_ if (psf_ftell (psf) == psf->filelength) return SF_TRUE ; + if (psf->is_pipe) { + return SF_TRUE; + } + return SF_FALSE ; } /* sf_flac_eof_callback */ @@ -405,6 +409,18 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_ psf->sf.samplerate = metadata->data.stream_info.sample_rate ; psf->sf.frames = metadata->data.stream_info.total_samples ; + /* if the file claims to have 0 frames, then it's a + * stream of unknown length. We then treat it almost like a pipe + * with unknown sample count and not being seekable. + * In contrast to a real pipe, we know the actual filesize, + * so we don't mess with it. + */ + if (0 == psf->sf.frames) { + psf->sf.frames = SF_COUNT_MAX; + psf->sf.seekable = SF_FALSE; + psf->is_pipe = true; + } + psf_log_printf (psf, "FLAC Stream Metadata\n Channels : %d\n Sample rate : %d\n Frames : %D\n", psf->sf.channels, psf->sf.samplerate, psf->sf.frames) ; switch (metadata->data.stream_info.bits_per_sample)