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.

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 */
                }
        }
 
_______________________________________________
flac-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/flac-dev

Reply via email to