From 204dfeae4ca33a40aa3a40ec5289f2e473ccfdb8 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sun, 31 Jul 2022 00:22:33 +0100 Subject: [PATCH 1/3] Prefer libflac over dr_flac when both are enabled --- src/music.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/music.c b/src/music.c index 86700bde8..b9bc767fa 100644 --- a/src/music.c +++ b/src/music.c @@ -164,12 +164,12 @@ static Mix_MusicInterface *s_music_interfaces[] = #ifdef MUSIC_WAV &Mix_MusicInterface_WAV, #endif -#ifdef MUSIC_FLAC_DRFLAC - &Mix_MusicInterface_DRFLAC, -#endif #ifdef MUSIC_FLAC_LIBFLAC &Mix_MusicInterface_FLAC, #endif +#ifdef MUSIC_FLAC_DRFLAC + &Mix_MusicInterface_DRFLAC, +#endif #ifdef MUSIC_OGG &Mix_MusicInterface_OGG, #endif From ad86326708ae9da948ab297c5513879eee6c91fc Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sun, 31 Jul 2022 00:23:00 +0100 Subject: [PATCH 2/3] Prefer libmpg123 over dr_mp3 when both are enabled --- src/music.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/music.c b/src/music.c index b9bc767fa..cd8688eb7 100644 --- a/src/music.c +++ b/src/music.c @@ -176,12 +176,12 @@ static Mix_MusicInterface *s_music_interfaces[] = #ifdef MUSIC_OPUS &Mix_MusicInterface_Opus, #endif -#ifdef MUSIC_MP3_DRMP3 - &Mix_MusicInterface_DRMP3, -#endif #ifdef MUSIC_MP3_MPG123 &Mix_MusicInterface_MPG123, #endif +#ifdef MUSIC_MP3_DRMP3 + &Mix_MusicInterface_DRMP3, +#endif #ifdef MUSIC_MOD_XMP &Mix_MusicInterface_XMP, #endif From a38cd65ff76cfce978fab57ac198df41e81c3351 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sun, 31 Jul 2022 01:13:28 +0100 Subject: [PATCH 3/3] Allow libvorbis and stb_vorbis to be enabled simultaneously --- Android.mk | 2 +- CMakeLists.txt | 3 +-- Makefile.os2 | 5 ++-- VisualC-WinRT/SDL_mixer-UWP.vcxproj | 12 +++++----- VisualC/SDL_mixer.vcxproj | 8 +++---- Xcode/SDL_mixer.xcodeproj/project.pbxproj | 6 ++--- configure | 2 +- configure.ac | 2 +- src/codecs/music_ogg.c | 2 +- src/codecs/music_ogg_stb.c | 4 ++-- src/codecs/music_ogg_stb.h | 28 +++++++++++++++++++++++ src/music.c | 4 ++++ 12 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 src/codecs/music_ogg_stb.h diff --git a/Android.mk b/Android.mk index dada259a5..87e4e0c5b 100644 --- a/Android.mk +++ b/Android.mk @@ -101,7 +101,7 @@ ifeq ($(SUPPORT_FLAC_LIBFLAC),true) endif ifeq ($(SUPPORT_OGG_STB),true) - LOCAL_CFLAGS += -DMUSIC_OGG -DOGG_USE_STB + LOCAL_CFLAGS += -DMUSIC_OGG_STB endif ifeq ($(SUPPORT_OGG),true) diff --git a/CMakeLists.txt b/CMakeLists.txt index 810e1856e..723a9e63a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,8 +395,7 @@ endif() if(SDL2MIXER_VORBIS_STB) message(STATUS "Enabled ogg music: using stb_vorbis") - target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OGG) - target_compile_definitions(SDL2_mixer PRIVATE OGG_USE_STB) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OGG_STB) endif() if(SDL2MIXER_VORBIS_TREMOR) diff --git a/Makefile.os2 b/Makefile.os2 index 4b2e53076..dff9dee26 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -99,15 +99,14 @@ VORBIS_LIBS=vorbisfile.lib vorbis.lib !endif !ifeq USE_OGG yes CFLAGS+= -DMUSIC_OGG -!ifeq USE_STBVORBIS yes -CFLAGS+= -DOGG_USE_STB -!else !ifeq USE_TREMOR yes CFLAGS+= -DOGG_USE_TREMOR !endif LIBS+= $(VORBIS_LIBS) NEED_LIBOGG=yes !endif +!ifeq USE_STBVORBIS yes +CFLAGS+= -DMUSIC_OGG_STB !endif !ifeq USE_FLAC yes diff --git a/VisualC-WinRT/SDL_mixer-UWP.vcxproj b/VisualC-WinRT/SDL_mixer-UWP.vcxproj index dd9db2367..45956b8dd 100644 --- a/VisualC-WinRT/SDL_mixer-UWP.vcxproj +++ b/VisualC-WinRT/SDL_mixer-UWP.vcxproj @@ -198,7 +198,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console @@ -211,7 +211,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console @@ -224,7 +224,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console @@ -237,7 +237,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console @@ -250,7 +250,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console @@ -263,7 +263,7 @@ NotUsing false ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\external\ogg\include;..\external\vorbis\include;..\..\SDL\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) Console diff --git a/VisualC/SDL_mixer.vcxproj b/VisualC/SDL_mixer.vcxproj index 7a2d4e4b5..58d3f5201 100644 --- a/VisualC/SDL_mixer.vcxproj +++ b/VisualC/SDL_mixer.vcxproj @@ -109,7 +109,7 @@ /D OGG_DYNAMIC=\"libvorbisfile-3.dll\" %(AdditionalOptions) Disabled ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\src\codecs\native_midi;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE + DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE MultiThreadedDLL Level3 OldStyle @@ -139,7 +139,7 @@ /D OGG_DYNAMIC=\"libvorbisfile-3.dll\" %(AdditionalOptions) Disabled ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\src\codecs\native_midi;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE + DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE MultiThreadedDLL Level3 OldStyle @@ -168,7 +168,7 @@ /D OGG_DYNAMIC=\"libvorbisfile-3.dll\" %(AdditionalOptions) ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\src\codecs\native_midi;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE;%(PreprocessorDefinitions) MultiThreadedDLL Level3 StreamingSIMDExtensions @@ -195,7 +195,7 @@ /D OGG_DYNAMIC=\"libvorbisfile-3.dll\" %(AdditionalOptions) ..\include;..\src;..\src\codecs;..\src\codecs\timidity;..\src\codecs\native_midi;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG;OGG_USE_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_FLAC_DRFLAC;MUSIC_MOD_XMP;XMP_DYNAMIC="libxmp-lite.dll";MUSIC_MP3_DRMP3;MUSIC_OGG_STB;MUSIC_OPUS;OPUS_DYNAMIC="libopusfile-0.dll";MUSIC_MID_TIMIDITY;MUSIC_MID_NATIVE;%(PreprocessorDefinitions) MultiThreadedDLL Level3 StreamingSIMDExtensions diff --git a/Xcode/SDL_mixer.xcodeproj/project.pbxproj b/Xcode/SDL_mixer.xcodeproj/project.pbxproj index 4ff992931..eb6750d00 100644 --- a/Xcode/SDL_mixer.xcodeproj/project.pbxproj +++ b/Xcode/SDL_mixer.xcodeproj/project.pbxproj @@ -773,8 +773,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( MUSIC_FLAC_DRFLAC, MUSIC_MP3_DRMP3, - MUSIC_OGG, - OGG_USE_STB, + MUSIC_OGG_STB, MUSIC_WAV, "$(CONFIG_PREPROCESSOR_DEFINITIONS)", ); @@ -823,8 +822,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( MUSIC_FLAC_DRFLAC, MUSIC_MP3_DRMP3, - MUSIC_OGG, - OGG_USE_STB, + MUSIC_OGG_STB, MUSIC_WAV, "$(CONFIG_PREPROCESSOR_DEFINITIONS)", ); diff --git a/configure b/configure index c167e8f77..916128e8e 100755 --- a/configure +++ b/configure @@ -17720,7 +17720,7 @@ fi if test x$enable_music_ogg = xyes -a x$enable_music_ogg_stb = xyes; then have_stb_vorbis=yes - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_STB" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG_STB" SDL2MIXER_VORBIS_STB=1 fi diff --git a/configure.ac b/configure.ac index 248ec2f6d..054440eca 100644 --- a/configure.ac +++ b/configure.ac @@ -577,7 +577,7 @@ AC_ARG_ENABLE(music-ogg-stb, [], enable_music_ogg_stb=yes) if test x$enable_music_ogg = xyes -a x$enable_music_ogg_stb = xyes; then have_stb_vorbis=yes - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_STB" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG_STB" SDL2MIXER_VORBIS_STB=1 fi diff --git a/src/codecs/music_ogg.c b/src/codecs/music_ogg.c index 16af47b9d..45e8b92a6 100644 --- a/src/codecs/music_ogg.c +++ b/src/codecs/music_ogg.c @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -#if defined(MUSIC_OGG) && !defined(OGG_USE_STB) +#ifdef MUSIC_OGG /* This file supports Ogg Vorbis music streams */ diff --git a/src/codecs/music_ogg_stb.c b/src/codecs/music_ogg_stb.c index b33f38e05..fca8fd2c7 100644 --- a/src/codecs/music_ogg_stb.c +++ b/src/codecs/music_ogg_stb.c @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -#if defined(MUSIC_OGG) && defined(OGG_USE_STB) +#ifdef MUSIC_OGG_STB /* This file supports Ogg Vorbis music streams using a modified stb_vorbis module */ @@ -447,7 +447,7 @@ static void OGG_Delete(void *context) SDL_free(music); } -Mix_MusicInterface Mix_MusicInterface_OGG = +Mix_MusicInterface Mix_MusicInterface_OGG_STB = { "OGG", MIX_MUSIC_OGG, diff --git a/src/codecs/music_ogg_stb.h b/src/codecs/music_ogg_stb.h new file mode 100644 index 000000000..5c7e78107 --- /dev/null +++ b/src/codecs/music_ogg_stb.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2022 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports Ogg Vorbis music streams */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_OGG_STB; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/music.c b/src/music.c index cd8688eb7..be1ce0956 100644 --- a/src/music.c +++ b/src/music.c @@ -34,6 +34,7 @@ #include "music_fluidsynth.h" #include "music_timidity.h" #include "music_ogg.h" +#include "music_ogg_stb.h" #include "music_opus.h" #include "music_drmp3.h" #include "music_mpg123.h" @@ -173,6 +174,9 @@ static Mix_MusicInterface *s_music_interfaces[] = #ifdef MUSIC_OGG &Mix_MusicInterface_OGG, #endif +#ifdef MUSIC_OGG_STB + &Mix_MusicInterface_OGG_STB, +#endif #ifdef MUSIC_OPUS &Mix_MusicInterface_Opus, #endif