[flac-dev] Windows file buffering

lvqcl lvqcl.mail at gmail.com
Thu Dec 10 10:52:53 PST 2015

Christoph Terasa wrote:

>> The attached patch *should* resolve the issue. libFLAC will call
>> setvbuf(file, ...)
>> only if GetFileType(...file...) == FILE_TYPE_DISK.
> I probably don't know enough about the intricates of Win32, but why not
> prefer this for clarity:

> -       setvbuf(file, NULL, _IOFBF, 10*1024*1024);
> +       if(file != stdout)
> +               setvbuf(file, NULL, _IOFBF, 10*1024*1024);
>   #endif
>          encoder->private_->file = file;
> Does libFLAC support other output types except for pipes/stdout and files?

But stdout is not the only existing pipe. A program that uses libFLAC can create
some other pipe (e.g. via popen()) and then call FLAC__stream_encoder_init_FILE().

> Also, if you want to be really evil you could even just use *else* and
> have the #ifdef _WIN32 block depend on the relative position to the if
> above...

I don't understand what you mean.

More information about the flac-dev mailing list