Merge pull request #449 from carlo-bramini/win-driver-selection

let cmake find WinMidi and DSound
This commit is contained in:
Tom M 2018-10-27 20:26:18 +02:00 committed by GitHub
commit 804cbf91c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 13 deletions

View File

@ -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 ( enable-network )
set ( WINDOWS_LIBS "${WINDOWS_LIBS};ws2_32" )
endif ( enable-network )
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 )
@ -229,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

View File

@ -1,5 +1,5 @@
#include "VersionInfo.h"
#include "winres.h"
#include "winver.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILE_VERSION_RESOURCE

View File

@ -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 )

View File

@ -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 )
@ -212,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
@ -227,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}
@ -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}

View File

@ -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@

View File

@ -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
}

View File

@ -137,8 +137,6 @@ typedef guint64 uint64_t;
#include <ws2tcpip.h> /* 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