Skip to content

Commit

Permalink
Detect SDL_InitSubSystem failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Clownacy committed Oct 30, 2019
1 parent 75c0060 commit cfdee35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions clownaudio/playback/sdl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ static void Callback(void *user_data, Uint8 *output_buffer_uint8, int bytes_to_d

bool Backend_Init(void)
{
bool success = true;

sdl_already_init = SDL_WasInit(SDL_INIT_AUDIO);

if (!sdl_already_init)
SDL_InitSubSystem(SDL_INIT_AUDIO);
if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
success = false;

return true;
return success;
}

void Backend_Deinit(void)
Expand Down
7 changes: 5 additions & 2 deletions clownaudio/playback/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ static void Callback(void *user_data, Uint8 *output_buffer_uint8, int bytes_to_d

bool Backend_Init(void)
{
bool success = true;

sdl_already_init = SDL_WasInit(SDL_INIT_AUDIO);

if (!sdl_already_init)
SDL_InitSubSystem(SDL_INIT_AUDIO);
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
success = false;

return true;
return success;
}

void Backend_Deinit(void)
Expand Down

0 comments on commit cfdee35

Please sign in to comment.