Skip to content

Commit 4ad11b3

Browse files
committed
Check MIX_Init()'s return code in the conftest
1 parent 4d116bc commit 4ad11b3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/conftests/sdl3_audio.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ int main(int, char** argv)
2626
return (EXIT_FAILURE);
2727
}
2828

29-
MIX_Init();
29+
if(!MIX_Init()) {
30+
fprintf(stdout, "Cannot initialize SDL Mixer: %s\n", SDL_GetError());
31+
return (EXIT_FAILURE);
32+
}
3033

3134
SDL_AudioSpec spec;
3235
spec.freq = 44100;
3336
spec.format = SDL_AUDIO_S16;
3437
spec.channels = 2;
3538
MIX_Mixer* mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec);
3639
if (!mixer) {
37-
fprintf(stdout, "Cannot initialize SDL Mixer: %s\n", SDL_GetError());
40+
fprintf(stdout, "Cannot initialize audio device: %s\n", SDL_GetError());
3841
return (EXIT_FAILURE);
3942
}
4043

@@ -60,5 +63,6 @@ int main(int, char** argv)
6063
fprintf(stdout, "Success\n");
6164
MIX_DestroyAudio(music);
6265
MIX_DestroyMixer(mixer);
66+
MIX_Quit();
6367
return (EXIT_SUCCESS);
6468
}

0 commit comments

Comments
 (0)