mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
I guess this is becoming the "try to make SDL_mixer work" branch
Move InitSubSystem calls into proper places, don't use AUDIO_S16LSB (bad according to SDL_mixer docs) Add error checking
This commit is contained in:
parent
b258b9b503
commit
6dda71bef7
3 changed files with 37 additions and 16 deletions
|
@ -1701,22 +1701,12 @@ void I_StartupGraphics(void)
|
||||||
keyboard_started = true;
|
keyboard_started = true;
|
||||||
|
|
||||||
#if !defined(HAVE_TTF)
|
#if !defined(HAVE_TTF)
|
||||||
#ifdef _WIN32 // Initialize Audio as well, otherwise Win32's DirectX can not use audio
|
// Previously audio was init here for questionable reasons?
|
||||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0)
|
|
||||||
#else //SDL_OpenAudio will do SDL_InitSubSystem(SDL_INIT_AUDIO)
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (SDL_WasInit(SDL_INIT_AUDIO)==0)
|
|
||||||
CONS_Printf(M_GetText("Couldn't initialize SDL's Audio System with Video System: %s\n"), SDL_GetError());
|
|
||||||
if (SDL_WasInit(SDL_INIT_VIDEO)==0)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError());
|
CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
char vd[100]; //stack space for video name
|
char vd[100]; //stack space for video name
|
||||||
|
|
|
@ -77,7 +77,16 @@ static INT32 current_track;
|
||||||
void I_StartupSound(void)
|
void I_StartupSound(void)
|
||||||
{
|
{
|
||||||
I_Assert(!sound_started);
|
I_Assert(!sound_started);
|
||||||
sound_started = true;
|
|
||||||
|
// EE inits audio first so we're following along.
|
||||||
|
if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO)
|
||||||
|
CONS_Printf("SDL Audio already started\n");
|
||||||
|
else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError());
|
||||||
|
// call to start audio failed -- we do not have it
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
midimode = false;
|
midimode = false;
|
||||||
music = NULL;
|
music = NULL;
|
||||||
|
@ -86,19 +95,31 @@ void I_StartupSound(void)
|
||||||
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
|
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
|
||||||
Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG);
|
Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG);
|
||||||
#endif
|
#endif
|
||||||
Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
|
|
||||||
|
if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "Error starting SDL_Mixer: %s\n", Mix_GetError());
|
||||||
|
// call to start audio failed -- we do not have it
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sound_started = true;
|
||||||
Mix_AllocateChannels(256);
|
Mix_AllocateChannels(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_ShutdownSound(void)
|
void I_ShutdownSound(void)
|
||||||
{
|
{
|
||||||
I_Assert(sound_started);
|
if (!sound_started)
|
||||||
|
return; // not an error condition
|
||||||
sound_started = false;
|
sound_started = false;
|
||||||
|
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
|
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
|
||||||
Mix_Quit();
|
Mix_Quit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGME
|
#ifdef HAVE_LIBGME
|
||||||
if (gme)
|
if (gme)
|
||||||
gme_delete(gme);
|
gme_delete(gme);
|
||||||
|
|
|
@ -1213,6 +1213,16 @@ void I_StartupSound(void)
|
||||||
// Configure sound device
|
// Configure sound device
|
||||||
CONS_Printf("I_StartupSound:\n");
|
CONS_Printf("I_StartupSound:\n");
|
||||||
|
|
||||||
|
// EE inits audio first so we're following along.
|
||||||
|
if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO)
|
||||||
|
CONS_Printf("SDL Audio already started\n");
|
||||||
|
else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "Error initializing SDL Audio: %s\n", SDL_GetError());
|
||||||
|
// call to start audio failed -- we do not have it
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Open the audio device
|
// Open the audio device
|
||||||
if (M_CheckParm ("-freq") && M_IsNextParm())
|
if (M_CheckParm ("-freq") && M_IsNextParm())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue