Conversation
Add SDL3 support
derselbst
left a comment
There was a problem hiding this comment.
Wow, that was quick. Thanks a lot! I've only got one comment below. Before merging it, I'll adapt the Window CI pipeline in the next days, to make it compile with SDL3 support.
Add SDL3 to Windows CI
Update sources
Fix callback
Remove .DS_Store
Fix init SDL3 subsystem
Fix SDL3 linking
Fix for finding SDL3 config and components
Remove SDL3_VERSION not defined check
Remove GetSDL3VersionFromHeaders
Fix init subsystem
Fix return
derselbst
left a comment
There was a problem hiding this comment.
Thanks for addressing the review findings. It's getting into shape. I found a few more minor issues.
src/drivers/fluid_sdl3.c
Outdated
| static void | ||
| SDLAudioCallback(void *data, SDL_AudioStream *stream, int add_len, int len) | ||
| { | ||
| void *buffer = malloc(len); |
There was a problem hiding this comment.
Memory allocation during audio playback is not real-time friendly. Is it possible to calculate the maximum len beforehand and use it to preallocate the biggest possible buffer?
There was a problem hiding this comment.
Added it to additional len as buffer.
There was a problem hiding this comment.
Sry, I think you misunderstood me. I was asking to get rid of the malloc from the callback and instead allocate the buffer in new_fluid_sdl3_audio_driver. Also note that dev->write_ptr takes the number of samples (audio frames) to synthesize, not the buffer length in bytes. See here for an example:
https://github.com/libsdl-org/SDL/blob/be991239d9bc6df06b0ca7a9ae9dbb7251e93c12/examples/audio/02-simple-playback-callback/simple-playback-callback.c#L25-L34
There was a problem hiding this comment.
I have replaced the malloc with a static buffer and for dev->write_ptr I use the buffer length divided by dev->frame_size
There was a problem hiding this comment.
Since it's a static buffer, you may remove the check for NULL in the same function since it generates a warning:
if (buffer == NULL)
{
return;
}The actual warning:
fluidsynth/src/drivers/fluid_sdl3.c:165:13: warning: comparison of array 'buffer' equal to a null pointer is always false [-Wtautological-pointer-compare]
if (buffer == NULL)
^~~~~~ ~~~~On the topic of warnings, the following call also triggers a -Wsign-compare warning on clang:
fluidsynth/src/drivers/fluid_sdl3.c:163:19: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
buf_len = SDL_min(add_len, SDL_arraysize(buffer));There was a problem hiding this comment.
Sry for nit-picking again. But you cannot use a buffer with a constant size. The size of the buffer must depend on audio.period-size that you've read in new_fluid_sdl3_audio_driver, otherwise there's no point in reading that setting. I suppose allocating a buffer size of period-size * frame_size would be reasonable.
There was a problem hiding this comment.
Buffer got updated to this.
I've added period_size to the dev structure.
There was a problem hiding this comment.
Reverted to malloc since the buffer can't be preallocated.
I have put the buffer inside the dev structure.
I have put the creation of the buffer in new_fluid_sdl3_audio_driver and the destruction of the buffer inside delete_fluid_sdl3_audio_driver.
|
@FtZPetruska I quickly smashed together a Windows CI build that works with SDL3. Even when resolving the cmake issues mentioned above, all the unit tests will be failing because of missing DLL - presumably SDL3.dll, e.g. here The unit tests inherit their link dependencies from the object lib This would carry over all add_library(SDL3::SDL3-shared SHARED IMPORTED)
set_target_properties(SDL3::SDL3-shared
PROPERTIES
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
IMPORTED_IMPLIB "${_sdl3_implib}"
IMPORTED_LOCATION "${_sdl3_dll}"
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
INTERFACE_SDL3_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL3"
)Is my understanding correct? And why isn't |
This SDL3 target looks properly set up:
What is most likely happening is that all the DLLs need to be copied to the same directory as the test executable. In CMake >=3.21 it can be done with: add_custom_command(TARGET ${_test} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${_test}> $<TARGET_FILE_DIR:${_test}>
COMMAND_EXPAND_LISTS
)Otherwise, if you know about the lists of DLLs needed, you can just use: add_custom_command(TARGET ${_test} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:SDL3::SDL3>
$<TARGET_FILE:other::dependency>
...
$<TARGET_FILE_DIR:${_test}>
)Also on the topic of CI, you may be interested in this Github Action: https://github.com/libsdl-org/setup-sdl |
Remove version check
Remove version check
Fix to work with buffer
Set SDL3 standard on
Add SDL3 to unit tests
Fix SDL3 no malloc
Fix target link libraries
Fix Windows CI with SDL3 on x86 and with MinGW
Fix dependencies
Fix buffer and SDL_min
Fix SDL3 playback
|
It is working! `fluidsynth /Users/andyvand/Downloads/fluidsynth/sf2/VintageDreamsWaves-v2.sf2 /Users/andyvand/Downloads/opentyrian2000/extras/music40.mid -a sdl3 fluidsynth: warning: Sample 'SineWave': ROM sample ignored |
Update buffer
Fix SDL buffer length
Fix MinGW compile
Revert to malloc for buffer
Buffer check
|
Ok, thanks so far. I'll merge this to a feature branch and will take care of the correct buffer allocation and fixing the CI build. |
fluidsynth 2.4.5
Prebuilt Windows Binaries were missing SDL3.dll
(FluidSynth/fluidsynth#1510)
Fix SDL3 intercepting signals, causing CTRL+C to not quit fluidsynth
(FluidSynth/fluidsynth#1509)
Fix a few flaws in the AWE32 NRPN implementation
(FluidSynth/fluidsynth#1452, FluidSynth/fluidsynth#1473)
A regression introduced in 2.4.4 broke drum preset selection for XG
MIDIs (FluidSynth/fluidsynth#1508)
Fix for OpenMP thread affinity crashes on Android devices
(FluidSynth/fluidsynth#1521, thanks to @looechao)
Fix fluidsynth's systemd user daemon being unable to create lock
file on some distros (FluidSynth/fluidsynth#1527, thanks to
@andrew-sayers)
Fix fluidsynth ignoring initialFilterFc generator limits
(FluidSynth/fluidsynth#1502)
A regression introduced in 2.3.6 prevented SF2 NRPN messages from
being processed correctly (FluidSynth/fluidsynth#1536)
fluidsynth 2.4.4
Support for SDL3 has been added, support for SDL2 has been
deprecated (FluidSynth/fluidsynth#1485, FluidSynth/fluidsynth#1478,
thanks to @andyvand)
Soundfonts that are not respecting the 46 zero-sample padding-space
previously sounded incorrect when
synth.dynamic-sample-loading was active (FluidSynth/fluidsynth#1484)
Allow drum channels to profit from Soundfont Bank Offsets by no
longer ignoring MSB Bank changes (FluidSynth/fluidsynth#1475)
Revise the preset fallback logic for drum channels
(FluidSynth/fluidsynth#1486)
A regression introduced in 2.4.1 may have caused interrupted
real-time playback when voices were using the lowpass filter
(FluidSynth/fluidsynth#1481)
Improve multi-user experience when running fluidsynth as systemd
service (FluidSynth/fluidsynth#1491, thanks to @andrew-sayers)
Fix ordering and dependencies of fluidsynth's systemd service
(FluidSynth/fluidsynth#1500, thanks to @fabiangreffrath)
Revise fluidsynth's man page (FluidSynth/fluidsynth#1499, thanks to
@fabiangreffrath)
fluidsynth 2.4.3
It was discovered, that exclusive class note terminations were too
slow (FluidSynth/fluidsynth#1467, thanks to @mrbumpy409)
Fix a regression introduced in 2.4.0 that allowed the amplitude of a
voice playing in delay phase to rise infinitely
(FluidSynth/fluidsynth#1451)
MSGS drum-style note-cut has been converted to an opt-in setting
synth.note-cut (FluidSynth/fluidsynth#1466)
Support for SDL2 has been disabled by default*
(FluidSynth/fluidsynth#1472)
Fix a regression introduced in 2.4.1 that could have caused infinite
audio gain output for some MIDI files under certain configurations
(FluidSynth/fluidsynth#1464)
Silence a warning issued by Systemd v254+
(FluidSynth/fluidsynth#1474, thanks to @andrew-sayers)
fluidsynth 2.4.2
Fix audible clicks when turning off voices while using a high filter
resonance (FluidSynth/fluidsynth#1427)
Fix a build failure with MSYS2 and MinGW when processing
VersionResource.rc (FluidSynth/fluidsynth#1448, thanks to @pedrolcl)
Fix a crash on startup when there are no MIDI devices available on
Windows (FluidSynth/fluidsynth#1446, thanks to @pedrolcl)
Restore discovery of libsndfile (FluidSynth/fluidsynth#1445)
Fix a race condition when loading SF3 files containing multiple
uncompressed samples (FluidSynth/fluidsynth#1457)
fluidsynth 2.4.1
Enable libsndfile to use filename with non-ASCII characters on
Windows (FluidSynth/fluidsynth#1416, thanks to @pedrolcl and
@stardusteyes)
Fix a few commandline encoding related issues on Windows
(FluidSynth/fluidsynth#1388, FluidSynth/fluidsynth#1421, thanks to
@pedrolcl)
Fix build errors on Windows (FluidSynth/fluidsynth#1419,
FluidSynth/fluidsynth#1422, thanks to @carlo-bramini)
Fix clicks and pops caused when changing parameters of the lowpass
filter (FluidSynth/fluidsynth#1415, FluidSynth/fluidsynth#1417,
FluidSynth/fluidsynth#1424)
Minor adjustment to AWE32 NRPN behavior (FluidSynth/fluidsynth#1430)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
fluidsynth 2.4.5
Prebuilt Windows Binaries were missing SDL3.dll
(FluidSynth/fluidsynth#1510)
Fix SDL3 intercepting signals, causing CTRL+C to not quit fluidsynth
(FluidSynth/fluidsynth#1509)
Fix a few flaws in the AWE32 NRPN implementation
(FluidSynth/fluidsynth#1452, FluidSynth/fluidsynth#1473)
A regression introduced in 2.4.4 broke drum preset selection for XG
MIDIs (FluidSynth/fluidsynth#1508)
Fix for OpenMP thread affinity crashes on Android devices
(FluidSynth/fluidsynth#1521, thanks to @looechao)
Fix fluidsynth's systemd user daemon being unable to create lock
file on some distros (FluidSynth/fluidsynth#1527, thanks to
@andrew-sayers)
Fix fluidsynth ignoring initialFilterFc generator limits
(FluidSynth/fluidsynth#1502)
A regression introduced in 2.3.6 prevented SF2 NRPN messages from
being processed correctly (FluidSynth/fluidsynth#1536)
fluidsynth 2.4.4
Support for SDL3 has been added, support for SDL2 has been
deprecated (FluidSynth/fluidsynth#1485, FluidSynth/fluidsynth#1478,
thanks to @andyvand)
Soundfonts that are not respecting the 46 zero-sample padding-space
previously sounded incorrect when
synth.dynamic-sample-loading was active (FluidSynth/fluidsynth#1484)
Allow drum channels to profit from Soundfont Bank Offsets by no
longer ignoring MSB Bank changes (FluidSynth/fluidsynth#1475)
Revise the preset fallback logic for drum channels
(FluidSynth/fluidsynth#1486)
A regression introduced in 2.4.1 may have caused interrupted
real-time playback when voices were using the lowpass filter
(FluidSynth/fluidsynth#1481)
Improve multi-user experience when running fluidsynth as systemd
service (FluidSynth/fluidsynth#1491, thanks to @andrew-sayers)
Fix ordering and dependencies of fluidsynth's systemd service
(FluidSynth/fluidsynth#1500, thanks to @fabiangreffrath)
Revise fluidsynth's man page (FluidSynth/fluidsynth#1499, thanks to
@fabiangreffrath)
fluidsynth 2.4.3
It was discovered, that exclusive class note terminations were too
slow (FluidSynth/fluidsynth#1467, thanks to @mrbumpy409)
Fix a regression introduced in 2.4.0 that allowed the amplitude of a
voice playing in delay phase to rise infinitely
(FluidSynth/fluidsynth#1451)
MSGS drum-style note-cut has been converted to an opt-in setting
synth.note-cut (FluidSynth/fluidsynth#1466)
Support for SDL2 has been disabled by default*
(FluidSynth/fluidsynth#1472)
Fix a regression introduced in 2.4.1 that could have caused infinite
audio gain output for some MIDI files under certain configurations
(FluidSynth/fluidsynth#1464)
Silence a warning issued by Systemd v254+
(FluidSynth/fluidsynth#1474, thanks to @andrew-sayers)
fluidsynth 2.4.2
Fix audible clicks when turning off voices while using a high filter
resonance (FluidSynth/fluidsynth#1427)
Fix a build failure with MSYS2 and MinGW when processing
VersionResource.rc (FluidSynth/fluidsynth#1448, thanks to @pedrolcl)
Fix a crash on startup when there are no MIDI devices available on
Windows (FluidSynth/fluidsynth#1446, thanks to @pedrolcl)
Restore discovery of libsndfile (FluidSynth/fluidsynth#1445)
Fix a race condition when loading SF3 files containing multiple
uncompressed samples (FluidSynth/fluidsynth#1457)
fluidsynth 2.4.1
Enable libsndfile to use filename with non-ASCII characters on
Windows (FluidSynth/fluidsynth#1416, thanks to @pedrolcl and
@stardusteyes)
Fix a few commandline encoding related issues on Windows
(FluidSynth/fluidsynth#1388, FluidSynth/fluidsynth#1421, thanks to
@pedrolcl)
Fix build errors on Windows (FluidSynth/fluidsynth#1419,
FluidSynth/fluidsynth#1422, thanks to @carlo-bramini)
Fix clicks and pops caused when changing parameters of the lowpass
filter (FluidSynth/fluidsynth#1415, FluidSynth/fluidsynth#1417,
FluidSynth/fluidsynth#1424)
Minor adjustment to AWE32 NRPN behavior (FluidSynth/fluidsynth#1430)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
fluidsynth 2.4.5
Prebuilt Windows Binaries were missing SDL3.dll
(FluidSynth/fluidsynth#1510)
Fix SDL3 intercepting signals, causing CTRL+C to not quit fluidsynth
(FluidSynth/fluidsynth#1509)
Fix a few flaws in the AWE32 NRPN implementation
(FluidSynth/fluidsynth#1452, FluidSynth/fluidsynth#1473)
A regression introduced in 2.4.4 broke drum preset selection for XG
MIDIs (FluidSynth/fluidsynth#1508)
Fix for OpenMP thread affinity crashes on Android devices
(FluidSynth/fluidsynth#1521, thanks to @looechao)
Fix fluidsynth's systemd user daemon being unable to create lock
file on some distros (FluidSynth/fluidsynth#1527, thanks to
@andrew-sayers)
Fix fluidsynth ignoring initialFilterFc generator limits
(FluidSynth/fluidsynth#1502)
A regression introduced in 2.3.6 prevented SF2 NRPN messages from
being processed correctly (FluidSynth/fluidsynth#1536)
fluidsynth 2.4.4
Support for SDL3 has been added, support for SDL2 has been
deprecated (FluidSynth/fluidsynth#1485, FluidSynth/fluidsynth#1478,
thanks to @andyvand)
Soundfonts that are not respecting the 46 zero-sample padding-space
previously sounded incorrect when
synth.dynamic-sample-loading was active (FluidSynth/fluidsynth#1484)
Allow drum channels to profit from Soundfont Bank Offsets by no
longer ignoring MSB Bank changes (FluidSynth/fluidsynth#1475)
Revise the preset fallback logic for drum channels
(FluidSynth/fluidsynth#1486)
A regression introduced in 2.4.1 may have caused interrupted
real-time playback when voices were using the lowpass filter
(FluidSynth/fluidsynth#1481)
Improve multi-user experience when running fluidsynth as systemd
service (FluidSynth/fluidsynth#1491, thanks to @andrew-sayers)
Fix ordering and dependencies of fluidsynth's systemd service
(FluidSynth/fluidsynth#1500, thanks to @fabiangreffrath)
Revise fluidsynth's man page (FluidSynth/fluidsynth#1499, thanks to
@fabiangreffrath)
fluidsynth 2.4.3
It was discovered, that exclusive class note terminations were too
slow (FluidSynth/fluidsynth#1467, thanks to @mrbumpy409)
Fix a regression introduced in 2.4.0 that allowed the amplitude of a
voice playing in delay phase to rise infinitely
(FluidSynth/fluidsynth#1451)
MSGS drum-style note-cut has been converted to an opt-in setting
synth.note-cut (FluidSynth/fluidsynth#1466)
Support for SDL2 has been disabled by default*
(FluidSynth/fluidsynth#1472)
Fix a regression introduced in 2.4.1 that could have caused infinite
audio gain output for some MIDI files under certain configurations
(FluidSynth/fluidsynth#1464)
Silence a warning issued by Systemd v254+
(FluidSynth/fluidsynth#1474, thanks to @andrew-sayers)
fluidsynth 2.4.2
Fix audible clicks when turning off voices while using a high filter
resonance (FluidSynth/fluidsynth#1427)
Fix a build failure with MSYS2 and MinGW when processing
VersionResource.rc (FluidSynth/fluidsynth#1448, thanks to @pedrolcl)
Fix a crash on startup when there are no MIDI devices available on
Windows (FluidSynth/fluidsynth#1446, thanks to @pedrolcl)
Restore discovery of libsndfile (FluidSynth/fluidsynth#1445)
Fix a race condition when loading SF3 files containing multiple
uncompressed samples (FluidSynth/fluidsynth#1457)
fluidsynth 2.4.1
Enable libsndfile to use filename with non-ASCII characters on
Windows (FluidSynth/fluidsynth#1416, thanks to @pedrolcl and
@stardusteyes)
Fix a few commandline encoding related issues on Windows
(FluidSynth/fluidsynth#1388, FluidSynth/fluidsynth#1421, thanks to
@pedrolcl)
Fix build errors on Windows (FluidSynth/fluidsynth#1419,
FluidSynth/fluidsynth#1422, thanks to @carlo-bramini)
Fix clicks and pops caused when changing parameters of the lowpass
filter (FluidSynth/fluidsynth#1415, FluidSynth/fluidsynth#1417,
FluidSynth/fluidsynth#1424)
Minor adjustment to AWE32 NRPN behavior (FluidSynth/fluidsynth#1430)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit dd8780e)
fluidsynth 2.4.5
Prebuilt Windows Binaries were missing SDL3.dll
(FluidSynth/fluidsynth#1510)
Fix SDL3 intercepting signals, causing CTRL+C to not quit fluidsynth
(FluidSynth/fluidsynth#1509)
Fix a few flaws in the AWE32 NRPN implementation
(FluidSynth/fluidsynth#1452, FluidSynth/fluidsynth#1473)
A regression introduced in 2.4.4 broke drum preset selection for XG
MIDIs (FluidSynth/fluidsynth#1508)
Fix for OpenMP thread affinity crashes on Android devices
(FluidSynth/fluidsynth#1521, thanks to @looechao)
Fix fluidsynth's systemd user daemon being unable to create lock
file on some distros (FluidSynth/fluidsynth#1527, thanks to
@andrew-sayers)
Fix fluidsynth ignoring initialFilterFc generator limits
(FluidSynth/fluidsynth#1502)
A regression introduced in 2.3.6 prevented SF2 NRPN messages from
being processed correctly (FluidSynth/fluidsynth#1536)
fluidsynth 2.4.4
Support for SDL3 has been added, support for SDL2 has been
deprecated (FluidSynth/fluidsynth#1485, FluidSynth/fluidsynth#1478,
thanks to @andyvand)
Soundfonts that are not respecting the 46 zero-sample padding-space
previously sounded incorrect when
synth.dynamic-sample-loading was active (FluidSynth/fluidsynth#1484)
Allow drum channels to profit from Soundfont Bank Offsets by no
longer ignoring MSB Bank changes (FluidSynth/fluidsynth#1475)
Revise the preset fallback logic for drum channels
(FluidSynth/fluidsynth#1486)
A regression introduced in 2.4.1 may have caused interrupted
real-time playback when voices were using the lowpass filter
(FluidSynth/fluidsynth#1481)
Improve multi-user experience when running fluidsynth as systemd
service (FluidSynth/fluidsynth#1491, thanks to @andrew-sayers)
Fix ordering and dependencies of fluidsynth's systemd service
(FluidSynth/fluidsynth#1500, thanks to @fabiangreffrath)
Revise fluidsynth's man page (FluidSynth/fluidsynth#1499, thanks to
@fabiangreffrath)
fluidsynth 2.4.3
It was discovered, that exclusive class note terminations were too
slow (FluidSynth/fluidsynth#1467, thanks to @mrbumpy409)
Fix a regression introduced in 2.4.0 that allowed the amplitude of a
voice playing in delay phase to rise infinitely
(FluidSynth/fluidsynth#1451)
MSGS drum-style note-cut has been converted to an opt-in setting
synth.note-cut (FluidSynth/fluidsynth#1466)
Support for SDL2 has been disabled by default*
(FluidSynth/fluidsynth#1472)
Fix a regression introduced in 2.4.1 that could have caused infinite
audio gain output for some MIDI files under certain configurations
(FluidSynth/fluidsynth#1464)
Silence a warning issued by Systemd v254+
(FluidSynth/fluidsynth#1474, thanks to @andrew-sayers)
fluidsynth 2.4.2
Fix audible clicks when turning off voices while using a high filter
resonance (FluidSynth/fluidsynth#1427)
Fix a build failure with MSYS2 and MinGW when processing
VersionResource.rc (FluidSynth/fluidsynth#1448, thanks to @pedrolcl)
Fix a crash on startup when there are no MIDI devices available on
Windows (FluidSynth/fluidsynth#1446, thanks to @pedrolcl)
Restore discovery of libsndfile (FluidSynth/fluidsynth#1445)
Fix a race condition when loading SF3 files containing multiple
uncompressed samples (FluidSynth/fluidsynth#1457)
fluidsynth 2.4.1
Enable libsndfile to use filename with non-ASCII characters on
Windows (FluidSynth/fluidsynth#1416, thanks to @pedrolcl and
@stardusteyes)
Fix a few commandline encoding related issues on Windows
(FluidSynth/fluidsynth#1388, FluidSynth/fluidsynth#1421, thanks to
@pedrolcl)
Fix build errors on Windows (FluidSynth/fluidsynth#1419,
FluidSynth/fluidsynth#1422, thanks to @carlo-bramini)
Fix clicks and pops caused when changing parameters of the lowpass
filter (FluidSynth/fluidsynth#1415, FluidSynth/fluidsynth#1417,
FluidSynth/fluidsynth#1424)
Minor adjustment to AWE32 NRPN behavior (FluidSynth/fluidsynth#1430)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit dd8780e)
(cherry picked from commit 8587135)
Add SDL3 support