shithub: choc

Download patch

ref: f700744969ac867649aa581ae19447a4c172179e
parent: 4f62dc3216e925731d378f2e7a5253259a34c4a1
parent: 406581948bb494b6bd8041f0026e59dbdd0de38f
author: Simon Howard <fraggle@soulsphere.org>
date: Tue Aug 25 03:59:05 EDT 2020

Merge pull request #1309 from chocolate-doom/openaudiodevice

replace uses of Mix_OpenAudio() with Mix_OpenAudioDevice()

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,8 +28,8 @@
                         "-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.
--- a/configure.ac
+++ b/configure.ac
@@ -31,8 +31,8 @@
         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.
--- a/midiproc/main.c
+++ b/midiproc/main.c
@@ -363,7 +363,7 @@
         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;
     }
--- a/opl/opl_sdl.c
+++ b/opl/opl_sdl.c
@@ -293,7 +293,7 @@
             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());
 
--- a/pcsound/pcsound_sdl.c
+++ b/pcsound/pcsound_sdl.c
@@ -200,7 +200,7 @@
 
         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());
 
--- a/src/i_musicpack.c
+++ b/src/i_musicpack.c
@@ -1134,7 +1134,7 @@
     {
         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());
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -185,7 +185,7 @@
         {
             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());
@@ -200,12 +200,8 @@
         }
     }
 
-#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.
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -1075,18 +1075,6 @@
 {
     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
@@ -1101,7 +1089,7 @@
         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;
--- a/src/i_timer.c
+++ b/src/i_timer.c
@@ -75,9 +75,8 @@
 {
     // initialize timer
 
-#if SDL_VERSION_ATLEAST(2, 0, 5)
     SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
-#endif
+
     SDL_Init(SDL_INIT_TIMER);
 }
 
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1285,9 +1285,7 @@
 
     // 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.