diff --git a/companion/src/companion.cpp b/companion/src/companion.cpp index 71641ee67..497723277 100644 --- a/companion/src/companion.cpp +++ b/companion/src/companion.cpp @@ -107,7 +107,9 @@ int main(int argc, char *argv[]) #ifdef SIMU_AUDIO sdlFlags |= SDL_INIT_AUDIO; #endif - SDL_Init(sdlFlags); + if (SDL_Init(sdlFlags) < 0) { + fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError()); + } #endif registerEEpromInterfaces(); diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index f3a7d7788..a2eb80a99 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -498,10 +498,15 @@ bool audio_thread_running = false; void *audio_thread(void *) { - if ( !SDL_WasInit(SDL_INIT_AUDIO) ) { - fprintf(stderr, "ERROR: couldn't initialize SDL audio support\n"); - return 0; - } + /* + Checking here if SDL audio was initialized is wrong, because + the SDL_CloseAudio() de-initializes it. + + if ( !SDL_WasInit(SDL_INIT_AUDIO) ) { + fprintf(stderr, "ERROR: couldn't initialize SDL audio support\n"); + return 0; + } + */ SDL_AudioSpec wanted, have; @@ -513,7 +518,10 @@ void *audio_thread(void *) wanted.callback = fill_audio; wanted.userdata = NULL; - /* Open the audio device, forcing the desired format */ + /* + SDL_OpenAudio() internally calls SDL_InitSubSystem(SDL_INIT_AUDIO), + which initializes SDL Audio subsystem if necessary + */ if ( SDL_OpenAudio(&wanted, &have) < 0 ) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); return 0;