Prefer early return on error in sound and MIDI init functions

git-svn-id: https://svn.eduke32.com/eduke32@8259 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/duke3d/src/sounds.cpp
#	source/duke3d/src/sounds_mapster32.cpp
#	source/sw/src/sounds.cpp
This commit is contained in:
hendricks266 2019-10-24 05:47:15 +00:00 committed by Christoph Oelckers
parent 14996d930b
commit 553dfb3544
2 changed files with 17 additions and 21 deletions

View file

@ -115,10 +115,13 @@ void S_MusicStartup(void)
{ {
initprintf("Initializing MIDI driver... "); initprintf("Initializing MIDI driver... ");
if (MUSIC_Init(ud.config.MusicDevice) == MUSIC_Ok || MUSIC_Init(0) == MUSIC_Ok || MUSIC_Init(1) == MUSIC_Ok) if (MUSIC_Init(ud.config.MusicDevice) != MUSIC_Ok && MUSIC_Init(0) != MUSIC_Ok && MUSIC_Init(1) != MUSIC_Ok)
{ {
MUSIC_SetVolume(mus_volume); initprintf("S_MusicStartup(): failed initializing\n");
return;
}
MUSIC_SetVolume(mus_volume);
auto const fil = kopen4load("d3dtimbr.tmb", 0); auto const fil = kopen4load("d3dtimbr.tmb", 0);
if (fil != buildvfs_kfd_invalid) if (fil != buildvfs_kfd_invalid)
@ -130,11 +133,6 @@ void S_MusicStartup(void)
Xfree(tmb); Xfree(tmb);
kclose(fil); kclose(fil);
} }
return;
}
initprintf("S_MusicStartup(): failed initializing\n");
} }
void S_MusicShutdown(void) void S_MusicShutdown(void)

View file

@ -1133,17 +1133,16 @@ SoundStartup(void)
status = FX_Init(NumVoices, NumChannels, MixRate, initdata); status = FX_Init(NumVoices, NumChannels, MixRate, initdata);
if (status == FX_Ok)
{
FxInitialized = TRUE;
snd_fxvolume.Callback();
snd_reversestereo.Callback();
}
if (status != FX_Ok) if (status != FX_Ok)
{ {
buildprintf("Sound error: %s\n",FX_ErrorString(FX_Error)); buildprintf("Sound error: %s\n",FX_ErrorString(FX_Error));
return;
} }
FxInitialized = TRUE;
snd_fxvolume.Callback();
snd_reversestereo.Callback();
FX_SetCallBack(SoundCallBack); FX_SetCallBack(SoundCallBack);
} }
@ -1201,17 +1200,16 @@ void MusicStartup(void)
buildprintf("Initializing MIDI driver... "); buildprintf("Initializing MIDI driver... ");
if (MUSIC_Init(MusicDevice) == MUSIC_Ok || MUSIC_Init(0) == MUSIC_Ok || MUSIC_Init(1) == MUSIC_Ok) if (MUSIC_Init(MusicDevice) != MUSIC_Ok && MUSIC_Init(0) != MUSIC_Ok && MUSIC_Init(1) != MUSIC_Ok)
{ {
MusicInitialized = TRUE; buildprintf("Music error: %s\n",MUSIC_ErrorString(MUSIC_Error));
MUSIC_SetVolume(mus_volume);
}
else
{
buildprintf("Music error: %s\n",MUSIC_ErrorString(MUSIC_ErrorCode));
mus_enabled = FALSE; mus_enabled = FALSE;
return;
} }
MusicInitialized = TRUE;
MUSIC_SetVolume(gs.MusicVolume);
#if 0 #if 0
if (MusicInitialized) if (MusicInitialized)
loadtmb(); loadtmb();
@ -1241,7 +1239,7 @@ MusicShutdown(void)
status = MUSIC_Shutdown(); status = MUSIC_Shutdown();
if (status != MUSIC_Ok) if (status != MUSIC_Ok)
{ {
buildprintf("Music error: %s\n",MUSIC_ErrorString(MUSIC_ErrorCode)); buildprintf("Music error: %s\n",MUSIC_ErrorString(MUSIC_Error));
} }
} }