From 9110943ef648bc03d1ac9daae805a88ac778e22e Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 29 Jun 2025 10:12:57 +0200 Subject: [PATCH 1/2] Remove deprecated SDL2 driver --- CMakeLists.txt | 22 -- FluidSynthConfig.cmake.in | 6 +- cmake_admin/GetSDL2VersionFromHeaders.cmake | 21 -- cmake_admin/report.cmake | 6 - doc/fluidsettings.xml | 8 +- src/CMakeLists.txt | 15 -- src/config.cmake | 3 - src/drivers/fluid_adriver.c | 10 - src/drivers/fluid_adriver.h | 7 - src/drivers/fluid_sdl2.c | 253 -------------------- src/fluidsynth.c | 7 +- 11 files changed, 8 insertions(+), 350 deletions(-) delete mode 100644 cmake_admin/GetSDL2VersionFromHeaders.cmake delete mode 100644 src/drivers/fluid_sdl2.c diff --git a/CMakeLists.txt b/CMakeLists.txt index db116568b..da2b424af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,6 @@ option ( enable-dsound "compile DirectSound support (if it is available)" on ) 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 ) @@ -689,27 +688,6 @@ if ( enable-libinstpatch ) endif ( InstPatch_FOUND ) 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 ) - include ( GetSDL2VersionFromHeaders ) - get_sdl2_version_from_headers("${SDL2_INCLUDE_DIRS}" SDL2_VERSION) - endif ( NOT DEFINED SDL2_VERSION ) - if ( SDL2_VERSION VERSION_LESS "2.0.4" ) - message ( STATUS "Found SDL2 version ${SDL2_VERSION}, but the minimum required is 2.0.4" ) - else ( SDL2_VERSION VERSION_LESS "2.0.4" ) - message ( STATUS "Found SDL2: ${SDL2_LIBRARIES} (version: ${SDL2_VERSION})" ) - set ( SDL2_SUPPORT 1 ) - list ( APPEND PC_REQUIRES_PRIV "sdl2") - endif ( SDL2_VERSION VERSION_LESS "2.0.4" ) - else ( SDL2_FOUND ) - message ( STATUS "Could NOT find SDL2 (Set SDL2_DIR to the directory containing its CMake config)" ) - endif ( SDL2_FOUND ) -endif ( enable-sdl2 ) - unset ( SDL3_SUPPORT CACHE ) if ( enable-sdl3 ) find_package ( SDL3 QUIET CONFIG COMPONENTS SDL3 ) diff --git a/FluidSynthConfig.cmake.in b/FluidSynthConfig.cmake.in index d8539a06e..21bdbcc0d 100644 --- a/FluidSynthConfig.cmake.in +++ b/FluidSynthConfig.cmake.in @@ -13,7 +13,7 @@ set(FLUIDSYNTH_SUPPORT_OSS @OSS_SUPPORT@) set(FLUIDSYNTH_SUPPORT_PIPEWIRE @PIPEWIRE_SUPPORT@) set(FLUIDSYNTH_SUPPORT_PORTAUDIO @PORTAUDIO_SUPPORT@) set(FLUIDSYNTH_SUPPORT_PULSE @PULSE_SUPPORT@) -set(FLUIDSYNTH_SUPPORT_SDL2 @SDL2_SUPPORT@) +set(FLUIDSYNTH_SUPPORT_SDL3 @SDL3_SUPPORT@) set(FLUIDSYNTH_SUPPORT_WASAPI @WASAPI_SUPPORT@) set(FLUIDSYNTH_SUPPORT_WAVEOUT @WAVEOUT_SUPPORT@) set(FLUIDSYNTH_SUPPORT_WINMIDI @WINMIDI_SUPPORT@) @@ -132,8 +132,8 @@ if(NOT FLUIDSYNTH_IS_SHARED) find_dependency(Readline) endif() - if(FLUIDSYNTH_SUPPORT_SDL2 AND NOT TARGET SDL2::SDL2) - find_dependency(SDL2) + if(FLUIDSYNTH_SUPPORT_SDL3 AND NOT TARGET SDL3::SDL3) + find_dependency(SDL3) endif() if(FLUIDSYNTH_SUPPORT_SYSTEMD AND NOT Systemd::libsystemd) diff --git a/cmake_admin/GetSDL2VersionFromHeaders.cmake b/cmake_admin/GetSDL2VersionFromHeaders.cmake deleted file mode 100644 index 836bcd3da..000000000 --- a/cmake_admin/GetSDL2VersionFromHeaders.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Get the version of SDL2 through headers -# This is needed for autotools builds before 2.0.12 -function(get_sdl2_version_from_headers INCLUDE_DIR OUT_VAR) - file(READ "${INCLUDE_DIR}/SDL_version.h" SDL_VERSION_H) - string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" - SDL2_MAJOR_RE "${SDL_VERSION_H}") - set(SDL2_MAJOR "${CMAKE_MATCH_1}") - string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" - SDL2_MINOR_RE "${SDL_VERSION_H}") - set(SDL2_MINOR "${CMAKE_MATCH_1}") - string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" SDL2_PATCH_RE - "${SDL_VERSION_H}") - set(SDL2_PATCH "${CMAKE_MATCH_1}") - if(SDL2_MAJOR_RE - AND SDL2_MINOR_RE - AND SDL2_PATCH_RE) - set(${OUT_VAR} - "${SDL2_MAJOR}.${SDL2_MINOR}.${SDL2_PATCH}" - PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake_admin/report.cmake b/cmake_admin/report.cmake index cf21b79ec..16950a69a 100644 --- a/cmake_admin/report.cmake +++ b/cmake_admin/report.cmake @@ -86,12 +86,6 @@ else ( PULSE_SUPPORT ) set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} PulseAudio: no\n" ) endif ( PULSE_SUPPORT ) -if ( SDL2_SUPPORT ) - set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} SDL2: yes\n" ) -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 ) diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 3cf600805..10d24a905 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -402,9 +402,9 @@ Developers: coreaudio (Mac OS X),
dart (OS/2) - alsa, coreaudio, dart, dsound, file, jack, oboe, opensles, oss, portaudio, pulseaudio, sdl2, sndman, wasapi, waveout + alsa, coreaudio, dart, dsound, file, jack, oboe, opensles, oss, portaudio, pulseaudio, sdl3, sndman, wasapi, waveout - The audio system to be used. In order to use sdl2 as audio driver, the application is responsible for initializing SDL's audio subsystem.

Note: sdl2 and waveout are available since fluidsynth 2.1. + The audio system to be used. In order to use sdl3 as audio driver, the application is responsible for initializing SDL's audio subsystem.

Note: waveout is available since fluidsynth 2.1.0, sdl3 since fluidsynth 2.4.4.
@@ -707,11 +707,11 @@ Developers: - sdl2.device + sdl3.device str default - Device to use for SDL2 driver output. + Device to use for SDL3 driver output. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ff0f17a9..c186f447b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,10 +69,6 @@ if ( WINMIDI_SUPPORT ) set ( fluid_winmidi_SOURCES drivers/fluid_winmidi.c ) endif ( WINMIDI_SUPPORT ) -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 ) @@ -258,7 +254,6 @@ add_library ( libfluidsynth-OBJ OBJECT ${fluid_wasapi_SOURCES} ${fluid_waveout_SOURCES} ${fluid_winmidi_SOURCES} - ${fluid_sdl2_SOURCES} ${fluid_sdl3_SOURCES} ${fluid_libinstpatch_SOURCES} ${fluid_osal_SOURCES} @@ -418,11 +413,6 @@ if ( TARGET InstPatch::libinstpatch AND LIBINSTPATCH_SUPPORT ) target_link_libraries ( libfluidsynth-OBJ PUBLIC InstPatch::libinstpatch ) endif() -if ( SDL2_SUPPORT ) - target_include_directories ( libfluidsynth-OBJ PRIVATE ${SDL2_INCLUDE_DIRS} ) - target_link_libraries ( libfluidsynth-OBJ PUBLIC ${SDL2_LIBRARIES} ) -endif() - if ( SDL3_SUPPORT ) target_link_libraries ( libfluidsynth-OBJ PUBLIC SDL3::SDL3 ) endif() @@ -519,11 +509,6 @@ if ( TARGET GLib2::glib-2 ) # because g_file_test() target_link_libraries ( fluidsynth PRIVATE GLib2::glib-2 ) endif() -if ( SDL2_SUPPORT ) # because SDL_Init() etc. - target_include_directories ( fluidsynth PRIVATE ${SDL2_INCLUDE_DIRS} ) - target_link_libraries ( fluidsynth PRIVATE ${SDL2_LIBRARIES} ) -endif() - if ( SDL3_SUPPORT ) target_link_libraries ( fluidsynth PUBLIC SDL3::SDL3 ) endif ( SDL3_SUPPORT ) diff --git a/src/config.cmake b/src/config.cmake index 64a38c73e..2e6ae554c 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -205,9 +205,6 @@ /* Define to enable Windows MIDI driver */ #cmakedefine WINMIDI_SUPPORT @WINMIDI_SUPPORT@ -/* Define to enable SDL2 audio driver */ -#cmakedefine SDL2_SUPPORT @SDL2_SUPPORT@ - /* Define to enable SDL3 audio driver */ #cmakedefine SDL3_SUPPORT @SDL3_SUPPORT@ diff --git a/src/drivers/fluid_adriver.c b/src/drivers/fluid_adriver.c index d86297f37..537709d72 100644 --- a/src/drivers/fluid_adriver.c +++ b/src/drivers/fluid_adriver.c @@ -199,16 +199,6 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] = }, #endif -#if SDL2_SUPPORT - { - "sdl2", - new_fluid_sdl2_audio_driver, - NULL, - delete_fluid_sdl2_audio_driver, - fluid_sdl2_audio_driver_settings - }, -#endif - #if AUFILE_SUPPORT { "file", diff --git a/src/drivers/fluid_adriver.h b/src/drivers/fluid_adriver.h index 849eaf7e3..f9afa3a2f 100644 --- a/src/drivers/fluid_adriver.h +++ b/src/drivers/fluid_adriver.h @@ -172,13 +172,6 @@ void delete_fluid_dart_audio_driver(fluid_audio_driver_t *p); void fluid_dart_audio_driver_settings(fluid_settings_t *settings); #endif -#if SDL2_SUPPORT -fluid_audio_driver_t *new_fluid_sdl2_audio_driver(fluid_settings_t *settings, - fluid_synth_t *synth); -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); diff --git a/src/drivers/fluid_sdl2.c b/src/drivers/fluid_sdl2.c deleted file mode 100644 index 3b6033c4d..000000000 --- a/src/drivers/fluid_sdl2.c +++ /dev/null @@ -1,253 +0,0 @@ -/* FluidSynth - A Software Synthesizer - * - * Copyright (C) 2003 Peter Hanappe and others. - * Copyright (C) 2018 Carlo Bramini - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see - * . - */ - -#include "fluid_synth.h" -#include "fluid_adriver.h" -#include "fluid_settings.h" - -#if SDL2_SUPPORT - -#include "SDL.h" - -typedef struct -{ - fluid_audio_driver_t driver; - - fluid_synth_t *synth; - fluid_audio_callback_t write_ptr; - - SDL_AudioDeviceID devid; - - int frame_size; - -} fluid_sdl2_audio_driver_t; - - -static void -SDLAudioCallback(void *data, void *stream, int len) -{ - fluid_sdl2_audio_driver_t *dev = (fluid_sdl2_audio_driver_t *)data; - - len /= dev->frame_size; - - dev->write_ptr(dev->synth, len, stream, 0, 2, stream, 1, 2); -} - -void fluid_sdl2_audio_driver_settings(fluid_settings_t *settings) -{ - int n, nDevs; - - fluid_settings_register_str(settings, "audio.sdl2.device", "default", 0); - fluid_settings_add_option(settings, "audio.sdl2.device", "default"); - - if(!SDL_WasInit(SDL_INIT_AUDIO)) - { -#if FLUID_VERSION_CHECK(FLUIDSYNTH_VERSION_MAJOR, FLUIDSYNTH_VERSION_MINOR, FLUIDSYNTH_VERSION_MICRO) < FLUID_VERSION_CHECK(2,2,0) - FLUID_LOG(FLUID_WARN, "SDL2 not initialized, SDL2 audio driver won't be usable"); -#endif - return; - } - - nDevs = SDL_GetNumAudioDevices(0); - - for(n = 0; n < nDevs; n++) - { - const char *dev_name = SDL_GetAudioDeviceName(n, 0); - - if(dev_name != NULL) - { - FLUID_LOG(FLUID_DBG, "SDL2 driver testing audio device: %s", dev_name); - fluid_settings_add_option(settings, "audio.sdl2.device", dev_name); - } - } -} - - -/* - * new_fluid_sdl2_audio_driver - */ -fluid_audio_driver_t * -new_fluid_sdl2_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth) -{ - fluid_sdl2_audio_driver_t *dev = NULL; - fluid_audio_callback_t write_ptr; - double sample_rate; - int period_size, sample_size; - SDL_AudioSpec aspec, rspec; - char *device; - const char *dev_name; - - /* Check if SDL library has been started */ - if(!SDL_WasInit(SDL_INIT_AUDIO)) - { - FLUID_LOG(FLUID_ERR, "Failed to create SDL2 audio driver, because the audio subsystem of SDL2 is not initialized."); - return NULL; - } - - /* Retrieve the settings */ - fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate); - fluid_settings_getint(settings, "audio.period-size", &period_size); - - /* Lower values do not seem to give good results */ - if(period_size < 1024) - { - period_size = 1024; - } - else - { - /* According to documentation, it MUST be a power of two */ - if((period_size & (period_size - 1)) != 0) - { - FLUID_LOG(FLUID_ERR, "\"audio.period-size\" must be a power of 2 for SDL2"); - return NULL; - } - } - /* Clear the format buffer */ - FLUID_MEMSET(&aspec, 0, sizeof(aspec)); - - /* Setup mixing frequency */ - aspec.freq = (int)sample_rate; - - /* Check the format */ - if(fluid_settings_str_equal(settings, "audio.sample-format", "float")) - { - FLUID_LOG(FLUID_DBG, "Selected 32 bit sample format"); - - sample_size = sizeof(float); - write_ptr = fluid_synth_write_float; - - aspec.format = AUDIO_F32SYS; - } - else if(fluid_settings_str_equal(settings, "audio.sample-format", "16bits")) - { - FLUID_LOG(FLUID_DBG, "Selected 16 bit sample format"); - - sample_size = sizeof(short); - write_ptr = fluid_synth_write_s16; - - aspec.format = AUDIO_S16SYS; - } - else - { - FLUID_LOG(FLUID_ERR, "Unhandled sample format"); - return NULL; - } - - /* Compile the format buffer */ - aspec.channels = 2; - aspec.samples = aspec.channels * ((period_size + 7) & ~7); - aspec.callback = (SDL_AudioCallback)SDLAudioCallback; - - /* Set default device to use */ - device = NULL; - dev_name = NULL; - - /* get the selected device name. if none is specified, use default device. */ - if(fluid_settings_dupstr(settings, "audio.sdl2.device", &device) == FLUID_OK - && device != NULL && device[0] != '\0') - { - int n, nDevs = SDL_GetNumAudioDevices(0); - - for(n = 0; n < nDevs; n++) - { - dev_name = SDL_GetAudioDeviceName(n, 0); - - if(FLUID_STRCASECMP(dev_name, device) == 0) - { - FLUID_LOG(FLUID_DBG, "Selected audio device GUID: %s", dev_name); - break; - } - } - - if(n >= nDevs) - { - FLUID_LOG(FLUID_DBG, "Audio device %s, using \"default\"", device); - dev_name = NULL; - } - } - - if(device != NULL) - { - FLUID_FREE(device); - } - - do - { - /* create and clear the driver data */ - dev = FLUID_NEW(fluid_sdl2_audio_driver_t); - - if(dev == NULL) - { - FLUID_LOG(FLUID_ERR, "Out of memory"); - break; - } - - FLUID_MEMSET(dev, 0, sizeof(fluid_sdl2_audio_driver_t)); - - /* set device pointer to userdata */ - aspec.userdata = dev; - - /* Save copy of synth */ - dev->synth = synth; - - /* Save copy of other variables */ - dev->write_ptr = write_ptr; - dev->frame_size = sample_size * aspec.channels; - - /* Open audio device */ - dev->devid = SDL_OpenAudioDevice(dev_name, 0, &aspec, &rspec, 0); - - if(!dev->devid) - { - FLUID_LOG(FLUID_ERR, "Failed to open audio device"); - break; - } - - /* 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); - - delete_fluid_sdl2_audio_driver(&dev->driver); - return NULL; -} - - -void delete_fluid_sdl2_audio_driver(fluid_audio_driver_t *d) -{ - fluid_sdl2_audio_driver_t *dev = (fluid_sdl2_audio_driver_t *) d; - - if(dev != NULL) - { - if(dev->devid) - { - /* Stop audio and close */ - SDL_PauseAudioDevice(dev->devid, 1); - SDL_CloseAudioDevice(dev->devid); - } - - FLUID_FREE(dev); - } -} - -#endif /* SDL2_SUPPORT */ diff --git a/src/fluidsynth.c b/src/fluidsynth.c index b5bbf3819..f6f5910a5 100644 --- a/src/fluidsynth.c +++ b/src/fluidsynth.c @@ -37,11 +37,6 @@ #define SDL_OK 1 #endif -#if SDL2_SUPPORT -#include -#define SDL_OK 0 -#endif - #if PIPEWIRE_SUPPORT #include #endif @@ -401,7 +396,7 @@ int main(int argc, char **argv) } #endif -#if SDL2_SUPPORT || SDL3_SUPPORT +#if SDL3_SUPPORT // Tell SDL that it shouldn't intercept signals, otherwise SIGINT and SIGTERM won't quit fluidsynth i = SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); if(i != SDL_OK) From a693cafbc11f0af2938a0215f03be1b08c2eb664 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 29 Jun 2025 11:29:54 +0200 Subject: [PATCH 2/2] Update alpine CI base image --- .azure/azure-pipelines-alpine.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure/azure-pipelines-alpine.yml b/.azure/azure-pipelines-alpine.yml index 17284bffe..a48798b72 100644 --- a/.azure/azure-pipelines-alpine.yml +++ b/.azure/azure-pipelines-alpine.yml @@ -30,7 +30,7 @@ stages: jobs: - job: DockerBuild pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-24.04' steps: - checkout: self @@ -64,7 +64,7 @@ stages: jobs: - job: Alpine pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-24.04' strategy: matrix: no-cflags: