Skip to content

Commit

Permalink
SDL3 Support (#1478)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyvand authored Feb 8, 2025
1 parent 698c659 commit 79999da
Show file tree
Hide file tree
Showing 9 changed files with 505 additions and 0 deletions.
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
11 changes: 11 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 @@ -683,6 +684,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
Loading

0 comments on commit 79999da

Please sign in to comment.