From d836053d241d76bc6676ec4991d95dce8be52a8d Mon Sep 17 00:00:00 2001 From: jthedering <51533355+jthedering@users.noreply.github.com> Date: Tue, 6 Nov 2012 19:07:24 +0000 Subject: [PATCH] Fixed: Benchmark.exe now writes to the user temp directory instead of its working directory, which is readonly for most users. Also improved error handling. --- Benchmark/Benchmark.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Benchmark/Benchmark.cpp b/Benchmark/Benchmark.cpp index 2955dd9..660b059 100644 --- a/Benchmark/Benchmark.cpp +++ b/Benchmark/Benchmark.cpp @@ -20,6 +20,7 @@ #include #define _USE_MATH_DEFINES #include +#include #include #include "../ParametricEQ.h" @@ -41,6 +42,11 @@ int main(int argc, char** argv) SF_INFO info; printf("Reading sound data from %s\n", argv[1]); SNDFILE* inFile = sf_open(argv[1], SFM_READ, &info); + if(inFile == NULL) + { + fprintf(stderr, "%s", sf_strerror(inFile)); + return 1; + } sampleRate = info.samplerate; channelCount = info.channels; @@ -70,14 +76,15 @@ int main(int argc, char** argv) buf = new float[frameCount * channelCount]; for(unsigned i=0;i= 3 && strlen(argv[2]) > 0) outPath = argv[2]; - printf("Writing output to %s\n", outPath); + else + { + char temp[255]; + GetTempPathA(sizeof(temp)/sizeof(wchar_t), temp); + + outPath = temp; + outPath += "testout.wav"; + } + + printf("Writing output to %s\n", outPath.c_str()); SF_INFO info = {frameCount, sampleRate, channelCount, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 0}; - SNDFILE* outFile = sf_open(outPath, SFM_WRITE, &info); + SNDFILE* outFile = sf_open(outPath.c_str(), SFM_WRITE, &info); + if(outFile == NULL) + { + fprintf(stderr, "%s", sf_strerror(outFile)); + return 1; + } sf_count_t numWritten = 0; while(numWritten < frameCount) @@ -111,5 +132,8 @@ int main(int argc, char** argv) delete[] buf; + if(argc < 3) + system("pause"); + return 0; }