Commit f0ee453c authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

Win32: Only use large buffers when writing to disk

Windows can suffer quite badly from disk fragmentations. To avoid
this, on Windows, the FILE* buffer size was set to 10Meg. However,
this huge buffer is undesireable when writing to a eg a pipe.

This patch updates the behaviour to only use the huge buffer when
writing to disk.

Patch-from: lvqcl <>
parent a51b27c0
......@@ -1330,7 +1330,8 @@ static FLAC__StreamEncoderInitStatus init_FILE_internal_(
* Windows can suffer quite badly from disk fragmentation. This can be
* reduced significantly by setting the output buffer size to be 10MB.
setvbuf(file, NULL, _IOFBF, 10*1024*1024);
if(GetFileType((HANDLE)_get_osfhandle(_fileno(file))) == FILE_TYPE_DISK)
setvbuf(file, NULL, _IOFBF, 10*1024*1024);
encoder->private_->file = file;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment