diff --git a/examples/common.h b/examples/common.h index 4e7e50f9558..ff21dab0140 100644 --- a/examples/common.h +++ b/examples/common.h @@ -189,7 +189,7 @@ class wav_writer { // Check if write was successful if (!fstream.good()) { - std::cerr << "Error writing to WAV file\n"; + fprintf(stderr, "Error writing to WAV file\n"); return false; // Stop writing and return an error } } diff --git a/examples/recorder/recorder.cpp b/examples/recorder/recorder.cpp index 461a2b82f30..7732cb0f85c 100644 --- a/examples/recorder/recorder.cpp +++ b/examples/recorder/recorder.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) { if (SDL_Init(SDL_INIT_AUDIO) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); - return false; + return -1; } SDL_SetHintWithPriority(SDL_HINT_AUDIO_RESAMPLING_MODE, "medium", SDL_HINT_OVERRIDE); @@ -71,7 +71,10 @@ int main(int argc, char **argv) { // main audio loop while (is_running) { audio.get(3000, pcmf32_new); - wavWriter.write(pcmf32_new.data(), pcmf32_new.size()); + if (!wavWriter.write(pcmf32_new.data(), pcmf32_new.size())) { + fprintf(stderr, "Failed to write audio data. Stopping.\n"); + return -1; + } // handle Ctrl + C is_running = sdl_poll_events();