Introduce enable-threads option to cmake (#463)

This commit is contained in:
carlo-bramini 2018-11-18 08:55:52 +01:00 committed by Tom M
parent 29c668683f
commit fe92a0a655
5 changed files with 20 additions and 3 deletions

View File

@ -72,6 +72,7 @@ option ( enable-winmidi "compile Windows MIDI support (if it is available)" on )
option ( enable-pkgconfig "use pkg-config to locate fluidsynth's (mostly optional) dependencies" on )
option ( enable-pulseaudio "compile PulseAudio support (if it is available)" on )
option ( enable-readline "compile readline lib line editing (if it is available)" on )
option ( enable-threads "enable threads support on multi-processor systems" on )
# Platform specific options
if ( CMAKE_SYSTEM MATCHES "Linux" )
@ -576,6 +577,11 @@ else ( enable-readline )
unset ( READLINE_LIBS CACHE )
endif ( enable-readline )
unset ( ENABLE_MIXER_THREADS CACHE )
if ( enable-threads )
set ( ENABLE_MIXER_THREADS 1 )
endif ( enable-threads )
unset ( HAVE_OPENMP CACHE )
find_package ( OpenMP QUIET )
if ( OpenMP_FOUND OR OpenMP_C_FOUND )

View File

@ -146,6 +146,12 @@ else ( HAVE_OPENMP )
message ( "OpenMP 4.0: no" )
endif ( HAVE_OPENMP )
if ( ENABLE_MIXER_THREADS )
message ( "Multi-thread support yes" )
else ( ENABLE_MIXER_THREADS )
message ( "Multi-thread support no" )
endif ( ENABLE_MIXER_THREADS )
if ( ENABLE_DEBUG )
message ( "Debug: yes" )
else ( ENABLE_DEBUG )

View File

@ -76,6 +76,9 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#cmakedefine HAVE_NETINET_TCP_H @HAVE_NETINET_TCP_H@
/* Define if compiling the mixer with multi-thread support */
#cmakedefine ENABLE_MIXER_THREADS @ENABLE_MIXER_THREADS@
/* Define if compiling with openMP to enable parallel audio rendering */
#cmakedefine HAVE_OPENMP @HAVE_OPENMP@

View File

@ -28,8 +28,6 @@
#include "fluid_synth.h"
#define ENABLE_MIXER_THREADS 1
// If less than x voices, the thread overhead is larger than the gain,
// so don't activate the thread(s).
#define VOICES_PER_THREAD 8

View File

@ -222,7 +222,11 @@ void fluid_synth_settings(fluid_settings_t *settings)
fluid_settings_register_int(settings, "synth.effects-groups", 1, 1, 128, 0);
fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 96000.0f, 0);
fluid_settings_register_int(settings, "synth.device-id", 0, 0, 126, 0);
#ifdef ENABLE_MIXER_THREADS
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0);
#else
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 1, 0);
#endif
fluid_settings_register_int(settings, "synth.min-note-length", 10, 0, 65535, 0);