diff --git a/CMakeLists.txt b/CMakeLists.txt index a5c740fe..4ce00a37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/cmake_admin/report.cmake b/cmake_admin/report.cmake index f9150e83..e25a989d 100644 --- a/cmake_admin/report.cmake +++ b/cmake_admin/report.cmake @@ -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 ) diff --git a/src/config.cmake b/src/config.cmake index f2d5256f..2d1d786b 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -76,6 +76,9 @@ /* Define to 1 if you have the 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@ diff --git a/src/rvoice/fluid_rvoice_mixer.c b/src/rvoice/fluid_rvoice_mixer.c index 062f6acf..af0ef75d 100644 --- a/src/rvoice/fluid_rvoice_mixer.c +++ b/src/rvoice/fluid_rvoice_mixer.c @@ -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 diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 9a061cbf..359d2e45 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -222,8 +222,12 @@ 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); fluid_settings_register_int(settings, "synth.threadsafe-api", 1, 0, 1, FLUID_HINT_TOGGLED);