From 4f75973f88b89d9b9dacd947ec980f8780a88192 Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:35:50 +0200 Subject: [PATCH 01/10] Print status of Windows drivers --- cmake_admin/report.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake_admin/report.cmake b/cmake_admin/report.cmake index de10487d..f9150e83 100644 --- a/cmake_admin/report.cmake +++ b/cmake_admin/report.cmake @@ -74,6 +74,18 @@ else ( WINDOWS_SUPPORT ) message ( "Windows: no" ) endif ( WINDOWS_SUPPORT ) +if ( DSOUND_SUPPORT ) + message ( "DSound: yes" ) +else ( DSOUND_SUPPORT ) + message ( "DSound: no" ) +endif ( DSOUND_SUPPORT ) + +if ( WINMIDI_SUPPORT ) + message ( "WinMidi support: yes" ) +else ( WINMIDI_SUPPORT ) + message ( "WinMidi support: no" ) +endif ( WINMIDI_SUPPORT ) + if ( LADSPA_SUPPORT ) message ( "LADSPA support: yes" ) else ( LADSPA_SUPPORT ) From f8c470d3f73ccec1c635ca610910dd3b4f8cedee Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:38:04 +0200 Subject: [PATCH 02/10] Don't use an MFC include. --- cmake_admin/VersionResource.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_admin/VersionResource.rc b/cmake_admin/VersionResource.rc index 3b01c1de..27bc7b30 100644 --- a/cmake_admin/VersionResource.rc +++ b/cmake_admin/VersionResource.rc @@ -1,5 +1,5 @@ #include "VersionInfo.h" -#include "winres.h" +#include "winver.h" VS_VERSION_INFO VERSIONINFO FILEVERSION FILE_VERSION_RESOURCE From 7b6ebbea5b4bd16a46ff018b7dc0e403f7b6d49a Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:41:34 +0200 Subject: [PATCH 03/10] Add Windows driver selection --- src/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43228ab5..70b7131a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,9 +78,13 @@ if ( PORTAUDIO_SUPPORT ) include_directories ( ${PORTAUDIO_INCLUDE_DIRS} ) endif ( PORTAUDIO_SUPPORT ) -if ( WINDOWS_SUPPORT ) - set ( fluid_windows_SOURCES drivers/fluid_dsound.c drivers/fluid_winmidi.c ) -endif ( WINDOWS_SUPPORT ) +if ( DSOUND_SUPPORT ) + set ( fluid_dsound_SOURCES drivers/fluid_dsound.c ) +endif ( DSOUND_SUPPORT ) + +if ( WINMIDI_SUPPORT ) + set ( fluid_winmidi_SOURCES drivers/fluid_winmidi.c ) +endif ( WINMIDI_SUPPORT ) if ( OSS_SUPPORT ) set ( fluid_oss_SOURCES drivers/fluid_oss.c ) @@ -243,7 +247,8 @@ add_library ( libfluidsynth-OBJ OBJECT ${fluid_oss_SOURCES} ${fluid_portaudio_SOURCES} ${fluid_pulse_SOURCES} - ${fluid_windows_SOURCES} + ${fluid_dsound_SOURCES} + ${fluid_winmidi_SOURCES} ${libfluidsynth_SOURCES} ${public_HEADERS} ${public_main_HEADER} From 8ef6ac7dcc3c2dc83b6853d158ac1259d22522e9 Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:42:15 +0200 Subject: [PATCH 04/10] Enable VersionInfo also for MINGW --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70b7131a..ae729f70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -216,7 +216,7 @@ configure_file ( ${CMAKE_SOURCE_DIR}/include/fluidsynth/version.h.in configure_file ( ${CMAKE_SOURCE_DIR}/include/fluidsynth.cmake ${public_main_HEADER} ) -if ( WIN32 AND NOT MINGW ) +if ( WIN32 ) include(generate_product_version) generate_product_version( VersionFilesOutputVariable @@ -231,7 +231,7 @@ generate_product_version( ORIGINAL_FILENAME "libfluidsynth.dll" FILE_DESCRIPTION "Fluidsynth" ) -endif ( WIN32 AND NOT MINGW ) +endif ( WIN32 ) add_library ( libfluidsynth-OBJ OBJECT ${config_SOURCES} From 413bcbeb8471e95e93fcf5d6d43921a33304c8f1 Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:43:27 +0200 Subject: [PATCH 05/10] Add Windows driver support macro. --- src/config.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/config.cmake b/src/config.cmake index aa222676..f2d5256f 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -190,6 +190,12 @@ /* Define to enable PulseAudio driver */ #cmakedefine PULSE_SUPPORT @PULSE_SUPPORT@ +/* Define to enable DirectSound driver */ +#cmakedefine DSOUND_SUPPORT @DSOUND_SUPPORT@ + +/* Define to enable Windows MIDI driver */ +#cmakedefine WINMIDI_SUPPORT @WINMIDI_SUPPORT@ + /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS @STDC_HEADERS@ From 30886a3d7851e870b516c90bce7a634205a2ec95 Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:44:27 +0200 Subject: [PATCH 06/10] Remove handwritten macros --- src/utils/fluidsynth_priv.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/fluidsynth_priv.h b/src/utils/fluidsynth_priv.h index 41e39839..d5dbdf7e 100644 --- a/src/utils/fluidsynth_priv.h +++ b/src/utils/fluidsynth_priv.h @@ -137,8 +137,6 @@ typedef guint64 uint64_t; #include /* Provides also socklen_t */ /* WIN32 special defines */ -#define DSOUND_SUPPORT 1 -#define WINMIDI_SUPPORT 1 #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 From 2ffad4dd2cd80335eac23693adc26c09c140e09b Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:48:01 +0200 Subject: [PATCH 07/10] Add options for Windows drivers --- CMakeLists.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c05c84b..18b52dc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,8 @@ option ( enable-libsndfile "compile libsndfile support (if it is available)" on option ( enable-midishare "compile MidiShare support (if it is available)" on ) option ( enable-network "enable network support (requires BSD sockets)" on ) option ( enable-oss "compile OSS support (if it is available)" on ) +option ( enable-dsound "compile DirectSound support (if it is available)" on ) +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 ) @@ -190,15 +192,34 @@ endif ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE # Windows unset ( WINDOWS_SUPPORT CACHE ) unset ( WINDOWS_LIBS CACHE ) +unset ( DSOUND_SUPPORT CACHE ) +unset ( WINMIDI_SUPPORT CACHE ) unset ( MINGW32 CACHE ) if ( WIN32 ) include ( CheckIncludeFiles ) + + # Check presence of MS include files check_include_file ( windows.h HAVE_WINDOWS_H ) check_include_file ( io.h HAVE_IO_H ) check_include_file ( dsound.h HAVE_DSOUND_H ) check_include_files ( "windows.h;mmsystem.h" HAVE_MMSYSTEM_H ) + set ( WINDOWS_SUPPORT ${HAVE_WINDOWS_H} ) - set ( WINDOWS_LIBS "dsound;winmm;ws2_32" ) + + if ( NETWORK_SUPPORT ) + set ( WINDOWS_LIBS "${WINDOWS_LIBS};ws2_32" ) + endif ( NETWORK_SUPPORT ) + + if ( enable-dsound AND HAVE_DSOUND_H ) + set ( WINDOWS_LIBS "${WINDOWS_LIBS};dsound" ) + set ( DSOUND_SUPPORT 1 ) + endif () + + if ( enable-winmidi AND HAVE_MMSYSTEM_H ) + set ( WINDOWS_LIBS "${WINDOWS_LIBS};winmm" ) + set ( WINMIDI_SUPPORT 1 ) + endif () + set ( LIBFLUID_CPPFLAGS "-DFLUIDSYNTH_DLL_EXPORTS" ) set ( FLUID_CPPFLAGS "-DFLUIDSYNTH_NOT_A_DLL" ) if ( MSVC ) From 02d7ab6939bcde016598d54b86ac6b6a2dff2a5c Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Fri, 26 Oct 2018 19:49:27 +0200 Subject: [PATCH 08/10] Fix "-mms-bitfields" option. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18b52dc5..312554f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,7 +250,7 @@ if ( WIN32 ) # MinGW compiler (a Windows GCC port) if ( MINGW ) set ( MINGW32 1 ) - add_definitions ( -mms-bitfields ) + add_compile_options ( -mms-bitfields ) endif ( MINGW ) else ( WIN32 ) # Check PThreads, but not in Windows From a1affca2ca17cc52a2b665fffb6cf0aba9639b96 Mon Sep 17 00:00:00 2001 From: carlo-bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Sat, 27 Oct 2018 10:11:28 +0200 Subject: [PATCH 09/10] Use "enable-network" instead of NETWORK_SUPPORT --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 312554f3..a5c740fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,9 +206,9 @@ if ( WIN32 ) set ( WINDOWS_SUPPORT ${HAVE_WINDOWS_H} ) - if ( NETWORK_SUPPORT ) + if ( enable-network ) set ( WINDOWS_LIBS "${WINDOWS_LIBS};ws2_32" ) - endif ( NETWORK_SUPPORT ) + endif ( enable-network ) if ( enable-dsound AND HAVE_DSOUND_H ) set ( WINDOWS_LIBS "${WINDOWS_LIBS};dsound" ) From e4ab5067f128dcefb87ef9fb3318c0ee75ee32bf Mon Sep 17 00:00:00 2001 From: derselbst Date: Sat, 27 Oct 2018 16:32:54 +0200 Subject: [PATCH 10/10] fix linker error on win32 without network support by adding missing #ifdefs --- src/utils/fluid_sys.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index 5a4a2dd9..e644ea5f 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -1330,9 +1330,10 @@ fluid_istream_gets(fluid_istream_t in, char *buf, int len) } else { +#ifdef NETWORK_SUPPORT n = recv(in & ~FLUID_SOCKET_FLAG, &c, 1, 0); - if(n == SOCKET_ERROR) +#endif { return -1; } @@ -1405,10 +1406,13 @@ fluid_ostream_printf(fluid_ostream_t out, const char *format, ...) return write(out, buf, FLUID_STRLEN(buf)); } +#ifdef NETWORK_SUPPORT /* Socket */ retval = send(out & ~FLUID_SOCKET_FLAG, buf, FLUID_STRLEN(buf), 0); - return retval != SOCKET_ERROR ? retval : -1; +#else + return -1; +#endif } #endif }