From f0ee453c23eacd1a10762b2301384ddc19821052 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Sat, 12 Dec 2015 08:23:22 +1100 Subject: [PATCH] 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 Closes: https://sourceforge.net/p/flac/feature-requests/114/ --- src/libFLAC/stream_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 203a271f..cd18a8bc 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -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); #endif encoder->private_->file = file;