Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SDL3 #1485

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .azure/azure-pipelines-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
matrix:
x86:
platform: Win32
platformAlt: x86
gtk-bundle: $(gtk-bundle-x86)
libsndfile-url: $(libsndfile-url-x86)
artifact-prefix: "fluidsynth"
Expand All @@ -35,6 +36,7 @@ jobs:
CMAKEFLAGS: "-Denable-libinstpatch=0"
x64:
platform: x64
platformAlt: x64
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
artifact-prefix: "fluidsynth"
Expand Down Expand Up @@ -79,6 +81,8 @@ jobs:
rmdir $(Build.ArtifactStagingDirectory)\libinstpatch-XP-$(platform)\
cd d:\deps
dir
cd lib
dir
DEL /F C:\Strawberry\perl\bin\pkg-config.bat
displayName: 'Prerequisites'
- script: |
Expand All @@ -92,6 +96,7 @@ jobs:
- script: |
@ECHO ON
SET "PATH=d:\deps\bin;%PATH%"
COPY d:\deps\lib\$(platformAlt)\SDL3* d:\deps\bin
cd build || exit -1
cmake --build . --config Release --target check || exit -1
displayName: 'Execute Unittests'
Expand All @@ -110,6 +115,8 @@ jobs:
del $(Build.ArtifactStagingDirectory)\bin\msvcp*.dll
del $(Build.ArtifactStagingDirectory)\lib\instpatch*.lib
del $(Build.ArtifactStagingDirectory)\lib\pkgconfig\libinstpatch*.pc
rd $(Build.ArtifactStagingDirectory)\lib\x86
rd $(Build.ArtifactStagingDirectory)\lib\x64
rd $(Build.ArtifactStagingDirectory)\include\libinstpatch-2 /s /q
displayName: 'Copy Artifacts'
- task: PublishBuildArtifacts@1
Expand Down Expand Up @@ -182,6 +189,7 @@ jobs:
- job: WindowsMinGW
variables:
artifact-prefix: "fluidsynth-mingw"
sdl3-subdir: 'x86_64-w64-mingw32'
strategy:
matrix:
x64:
Expand Down Expand Up @@ -233,11 +241,12 @@ jobs:
rm -rf libsndfile-*
cd mingw*\ && cp -rf * .. && cd .. && rm -rf mingw* || exit -1
cd $(Build.ArtifactStagingDirectory)\libinstpatch-$(platform) && cp -rf * d:\deps\ && mv -f * .. && cd .. && rmdir $(Build.ArtifactStagingDirectory)\libinstpatch-$(platform)\ || exit -1
dir
DEL /F C:\Strawberry\perl\bin\pkg-config.bat
displayName: 'Prerequisites'
- script: |
@ECHO ON
SET "PATH=d:\deps\bin;%PATH%"
SET "PATH=d:\deps\bin;d:\deps\$(sdl3-subdir)\bin;%PATH%"
REM remove that path from PATH to make sure sh.exe is not found (cmake will complain otherwise)
set PATH=%PATH:C:\Program Files\Git\bin;=%
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
Expand All @@ -248,7 +257,7 @@ jobs:
displayName: 'Compile fluidsynth'
- script: |
@ECHO ON
SET "PATH=d:\deps\bin;%PATH%"
SET "PATH=d:\deps\bin;d:\deps\$(sdl3-subdir)\bin;%PATH%"
REM remove that path from PATH to make sure sh.exe is not found (cmake will complain otherwise)
set PATH=%PATH:C:\Program Files\Git\bin;=%
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
Expand All @@ -257,7 +266,7 @@ jobs:
displayName: 'Execute Unittests'
- script: |
@ECHO ON
SET "PATH=d:\deps\bin;%PATH%"
SET "PATH=d:\deps\bin;d:\deps\$(sdl3-subdir)\bin;%PATH%"
REM remove that path from PATH to make sure sh.exe is not found (cmake will complain otherwise)
set PATH=%PATH:C:\Program Files\Git\bin;=%
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
build/

CMakeCache.txt
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ option ( enable-wasapi "compile Windows WASAPI support (if it is available)" on
option ( enable-waveout "compile Windows WaveOut support (if it is available)" on )
option ( enable-winmidi "compile Windows MIDI support (if it is available)" on )
option ( enable-sdl2 "compile SDL2 audio support (if it is available)" off )
option ( enable-sdl3 "compile SDL3 audio support (if it is available)" on )
option ( enable-pulseaudio "compile PulseAudio support (if it is available)" on )
option ( enable-pipewire "compile PipeWire support (if it is available)" on )
option ( enable-readline "compile readline lib line editing (if it is available)" on )
Expand Down Expand Up @@ -665,6 +666,7 @@ endif ( enable-libinstpatch )

unset ( SDL2_SUPPORT CACHE )
if ( enable-sdl2 )
message ( WARNING "SDL2 support is deprecated and will be removed in fluidsynth 2.5.0! Pls. use sdl3.")
find_package ( SDL2 QUIET )
if ( SDL2_FOUND )
if ( NOT DEFINED SDL2_VERSION )
Expand All @@ -683,6 +685,16 @@ if ( enable-sdl2 )
endif ( SDL2_FOUND )
endif ( enable-sdl2 )

unset ( SDL3_SUPPORT CACHE )
if ( enable-sdl3 )
find_package ( SDL3 QUIET CONFIG COMPONENTS SDL3 )
if ( SDL3_FOUND )
message ( STATUS "Found SDL3: ${SDL3_LIBRARIES} (version: ${SDL3_VERSION})" )
set ( SDL3_SUPPORT TRUE )
list ( APPEND PC_REQUIRES_PRIV "sdl3")
endif ( SDL3_FOUND )
endif ( enable-sdl3 )

unset ( OBOE_SUPPORT CACHE )
if ( enable-oboe )
find_package ( oboe )
Expand Down
6 changes: 6 additions & 0 deletions cmake_admin/report.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ else ( SDL2_SUPPORT )
set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} SDL2: no\n" )
endif ( SDL2_SUPPORT )

if ( SDL3_SUPPORT )
set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} SDL3: yes\n" )
else ( SDL3_SUPPORT )
set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} SDL3: no\n" )
endif ( SDL3_SUPPORT )

if ( WASAPI_SUPPORT )
set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} WASAPI: yes\n" )
else ( WASAPI_SUPPORT )
Expand Down
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ if ( SDL2_SUPPORT )
set ( fluid_sdl2_SOURCES drivers/fluid_sdl2.c )
endif ( SDL2_SUPPORT )

if ( SDL3_SUPPORT )
set ( fluid_sdl3_SOURCES drivers/fluid_sdl3.c )
endif ( SDL3_SUPPORT )

if ( OSS_SUPPORT )
set ( fluid_oss_SOURCES drivers/fluid_oss.c )
endif ( OSS_SUPPORT )
Expand Down Expand Up @@ -240,6 +244,7 @@ add_library ( libfluidsynth-OBJ OBJECT
${fluid_waveout_SOURCES}
${fluid_winmidi_SOURCES}
${fluid_sdl2_SOURCES}
${fluid_sdl3_SOURCES}
${fluid_libinstpatch_SOURCES}
${libfluidsynth_SOURCES}
${public_HEADERS}
Expand Down Expand Up @@ -397,6 +402,10 @@ if ( SDL2_SUPPORT )
target_link_libraries ( libfluidsynth-OBJ PUBLIC ${SDL2_LIBRARIES} )
endif()

if ( SDL3_SUPPORT )
target_link_libraries ( libfluidsynth-OBJ PUBLIC SDL3::SDL3 )
endif()

if ( TARGET oboe::oboe AND OBOE_SUPPORT )
target_link_libraries ( libfluidsynth-OBJ PUBLIC oboe::oboe )
endif()
Expand Down Expand Up @@ -494,6 +503,10 @@ if ( SDL2_SUPPORT ) # because SDL_Init() etc.
target_link_libraries ( fluidsynth PRIVATE ${SDL2_LIBRARIES} )
endif()

if ( SDL3_SUPPORT )
target_link_libraries ( fluidsynth PUBLIC SDL3::SDL3 )
endif ( SDL3_SUPPORT )

if ( TARGET PipeWire::PipeWire AND PIPEWIRE_SUPPORT ) # because pw_init() etc.
target_link_libraries ( fluidsynth PRIVATE PipeWire::PipeWire )
endif()
Expand Down
3 changes: 3 additions & 0 deletions src/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
/* Define to enable SDL2 audio driver */
#cmakedefine SDL2_SUPPORT @SDL2_SUPPORT@

/* Define to enable SDL3 audio driver */
#cmakedefine SDL3_SUPPORT @SDL3_SUPPORT@

/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS @STDC_HEADERS@

Expand Down
10 changes: 10 additions & 0 deletions src/drivers/fluid_adriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] =
},
#endif

#if SDL3_SUPPORT
{
"sdl3",
new_fluid_sdl3_audio_driver,
NULL,
delete_fluid_sdl3_audio_driver,
fluid_sdl3_audio_driver_settings
},
#endif

#if SDL2_SUPPORT
{
"sdl2",
Expand Down
7 changes: 7 additions & 0 deletions src/drivers/fluid_adriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ void delete_fluid_sdl2_audio_driver(fluid_audio_driver_t *p);
void fluid_sdl2_audio_driver_settings(fluid_settings_t *settings);
#endif

#if SDL3_SUPPORT
fluid_audio_driver_t *new_fluid_sdl3_audio_driver(fluid_settings_t *settings,
fluid_synth_t *synth);
void delete_fluid_sdl3_audio_driver(fluid_audio_driver_t *p);
void fluid_sdl3_audio_driver_settings(fluid_settings_t *settings);
#endif

#if AUFILE_SUPPORT
fluid_audio_driver_t *new_fluid_file_audio_driver(fluid_settings_t *settings,
fluid_synth_t *synth);
Expand Down
1 change: 1 addition & 0 deletions src/drivers/fluid_sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ new_fluid_sdl2_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
/* Start to play */
SDL_PauseAudioDevice(dev->devid, 0);

FLUID_LOG(FLUID_WARN, "SDL2 support is deprecated and will be removed in fluidsynth 2.5.0! Pls. use sdl3.");
return (fluid_audio_driver_t *) dev;
}
while(0);
Expand Down
Loading