[flac-dev] Disk fragmentation

Erik de Castro Lopo mle+la at mega-nerd.com
Fri Sep 26 22:44:30 PDT 2014

lvqcl wrote:

> IMHO it's better to move setvbuf() out of libFLAC/stream_encoder.c
> into flac/encode.c.

Why do you thing that is better?

> I can see two ways to do this:
> 1) Add a new function to libFLAC API that have access to
> encoder->private_->file and can call setvbuf:
> FLAC_API FLAC__bool FLAC__stream_encoder_set_buffer_size(FLAC__StreamEncoder *encoder, unsigned size);

Not real keen on changing the API just for this issue.

> 2) Rewrite EncoderSession_init_encoder() in flac/encode.c so that it
> opens the file, calls setvbuf and then uses FLAC__stream_encoder_init[_ogg]_stream()
> instead of FLAC__stream_encoder_init[_ogg]_file(). It's more difficult,
> but doesn't require API change.

That is a solution, but I'm still undecied on whether we actually
need to do it outside of libFLAC/stream_encoder.c. IN fact, doing
it there has the advantage of fixing it for Windows users of the
library as well as Windows users of the flac executable.

Erik de Castro Lopo

More information about the flac-dev mailing list