From 6a6207b52a86b1d7980a5233e297c0fc948bed7d Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Wed, 24 Sep 2014 06:35:14 +1000 Subject: [PATCH] stream_encoder.c : Give the encoder a larger stdio buffer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows in particular can experience slow encoding speeds on highly fragmented disks. Using setvbuf to increase the size of the buffer to 10Meg. This is probably not needed on Linux/Unix, but is very unlikely to to cause any negative effects. Patch-from: Janne Hyvärinen --- src/libFLAC/stream_encoder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 6f46d784..bd956340 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -1288,6 +1288,8 @@ static FLAC__StreamEncoderInitStatus init_FILE_internal_( if(file == stdout) file = get_binary_stdout_(); /* just to be safe */ + setvbuf(file, NULL, _IOFBF, 10*1024*1024); /* 10MB output buffer to help reduce disk fragmentation */ + encoder->private_->file = file; encoder->private_->progress_callback = progress_callback;