After considerable testing and bugfixing, I have finally finished converting from using file pointers to file descriptors. Unfortunately, the change most likely breaks compilation on windows, but parallel I/O is likely not going to work in windows anyway so all I need to do is write another wrapper function.
I've spent the last day or so testing the new code and so far everything seems to work properly. During the conversion I also located several odd edge-case bugs and fixed them. eg: if opening the output wav file succeeds but writing the RIFF headers to it fails, the program will continue trying to encode anyway.
The next commit or two will likely be cleaning up what I've changed a bit, then I will get back to the restructure, which is now ahead of schedule!