Skip to content

Commit

Permalink
Merge pull request #1309 from chocolate-doom/openaudiodevice
Browse files Browse the repository at this point in the history
replace uses of Mix_OpenAudio() with Mix_OpenAudioDevice()
  • Loading branch information
fragglet committed Aug 25, 2020
2 parents 4f62dc3 + 4065819 commit f700744
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 30 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -28,8 +28,8 @@ else()
"-Wredundant-decls")
endif()

find_package(SDL2 2.0.1)
find_package(SDL2_mixer 2.0.0)
find_package(SDL2 2.0.7)
find_package(SDL2_mixer 2.0.2)
find_package(SDL2_net 2.0.0)

# Check for libsamplerate.
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Expand Up @@ -31,8 +31,8 @@ then
CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS"
fi

PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.1])
PKG_CHECK_MODULES(SDLMIXER, [SDL2_mixer >= 2.0.0])
PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.7])
PKG_CHECK_MODULES(SDLMIXER, [SDL2_mixer >= 2.0.2])
PKG_CHECK_MODULES(SDLNET, [SDL2_net >= 2.0.0])

# Check for bash-completion.
Expand Down
2 changes: 1 addition & 1 deletion midiproc/main.c
Expand Up @@ -363,7 +363,7 @@ boolean InitSDL()
return false;
}

if (Mix_OpenAudio(snd_samplerate, MIX_DEFAULT_FORMAT, 2, 2048) < 0)
if (Mix_OpenAudioDevice(snd_samplerate, MIX_DEFAULT_FORMAT, 2, 2048, NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion opl/opl_sdl.c
Expand Up @@ -293,7 +293,7 @@ static int OPL_SDL_Init(unsigned int port_base)
return 0;
}

if (Mix_OpenAudio(opl_sample_rate, AUDIO_S16SYS, 2, GetSliceSize()) < 0)
if (Mix_OpenAudioDevice(opl_sample_rate, AUDIO_S16SYS, 2, GetSliceSize(), NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError());

Expand Down
2 changes: 1 addition & 1 deletion pcsound/pcsound_sdl.c
Expand Up @@ -200,7 +200,7 @@ static int PCSound_SDL_Init(pcsound_callback_func callback_func)

slicesize = GetSliceSize();

if (Mix_OpenAudio(pcsound_sample_rate, AUDIO_S16SYS, 2, slicesize) < 0)
if (Mix_OpenAudioDevice(pcsound_sample_rate, AUDIO_S16SYS, 2, slicesize, NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
fprintf(stderr, "Error initializing SDL_mixer: %s\n", Mix_GetError());

Expand Down
2 changes: 1 addition & 1 deletion src/i_musicpack.c
Expand Up @@ -1134,7 +1134,7 @@ static boolean I_MP_InitMusic(void)
{
fprintf(stderr, "Unable to set up sound.\n");
}
else if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, 1024) < 0)
else if (Mix_OpenAudioDevice(snd_samplerate, AUDIO_S16SYS, 2, 1024, NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
fprintf(stderr, "Error initializing SDL_mixer: %s\n",
Mix_GetError());
Expand Down
6 changes: 1 addition & 5 deletions src/i_sdlmusic.c
Expand Up @@ -185,7 +185,7 @@ static boolean I_SDL_InitMusic(void)
{
fprintf(stderr, "Unable to set up sound.\n");
}
else if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, 1024) < 0)
else if (Mix_OpenAudioDevice(snd_samplerate, AUDIO_S16SYS, 2, 1024, NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
fprintf(stderr, "Error initializing SDL_mixer: %s\n",
Mix_GetError());
Expand All @@ -200,12 +200,8 @@ static boolean I_SDL_InitMusic(void)
}
}

#if defined(SDL_MIXER_VERSION_ATLEAST)
#if SDL_MIXER_VERSION_ATLEAST(2,0,2)
// Initialize SDL_Mixer for MIDI music playback
Mix_Init(MIX_INIT_MID);
#endif
#endif

// Once initialization is complete, the temporary Timidity config
// file can be removed.
Expand Down
14 changes: 1 addition & 13 deletions src/i_sdlsound.c
Expand Up @@ -1075,18 +1075,6 @@ static boolean I_SDL_InitSound(boolean _use_sfx_prefix)
{
int i;

// SDL 2.0.6 has a bug that makes it unusable.
if (SDL_COMPILEDVERSION == SDL_VERSIONNUM(2, 0, 6))
{
I_Error(
"I_SDL_InitSound: "
"You are trying to launch with SDL 2.0.6 which has a known bug "
"that makes the game crash. Please either downgrade to "
"SDL 2.0.5 or upgrade to 2.0.7. See the following bug for some "
"additional context:\n"
"<https://github.com/chocolate-doom/chocolate-doom/issues/945>");
}

use_sfx_prefix = _use_sfx_prefix;

// No sounds yet
Expand All @@ -1101,7 +1089,7 @@ static boolean I_SDL_InitSound(boolean _use_sfx_prefix)
return false;
}

if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0)
if (Mix_OpenAudioDevice(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize(), NULL, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) < 0)
{
fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError());
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/i_timer.c
Expand Up @@ -75,9 +75,8 @@ void I_InitTimer(void)
{
// initialize timer

#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
#endif

SDL_Init(SDL_INIT_TIMER);
}

2 changes: 0 additions & 2 deletions src/i_video.c
Expand Up @@ -1285,9 +1285,7 @@ static void SetVideoMode(void)

// Force integer scales for resolution-independent rendering.

#if SDL_VERSION_ATLEAST(2, 0, 5)
SDL_RenderSetIntegerScale(renderer, integer_scaling);
#endif

// Blank out the full screen area in case there is any junk in
// the borders that won't otherwise be overwritten.
Expand Down

0 comments on commit f700744

Please sign in to comment.