[flac-dev] Patch to add buffering to decoding too

Janne Hyvärinen cse at sci.fi
Thu Sep 25 13:01:30 PDT 2014


Decoding flac files is also prone to producing fragmented files. NTFS 
has the ability to completely avoid fragmentation if it is told the file 
size before hand, but that would require using special Windows-only 
functions. Increasing the write buffer from the default 512 bytes to 10 
MB already reduces the problem tremendously.

-------------- next part --------------
diff --git a/src/flac/decode.c b/src/flac/decode.c
index 5e5e17a..9e9405c 100644
--- a/src/flac/decode.c
+++ b/src/flac/decode.c
@@ -251,6 +251,7 @@ FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__
 				DecoderSession_destroy(d, /*error_occurred=*/true);
 				return false;
 			}
+			setvbuf(d->fout, NULL, _IOFBF, 10*1024*1024); /* 10MB output buffer to help reduce disk fragmentation */
 		}
 	}
 


More information about the flac-dev mailing list