From 1bf9ad3e36f067ca142de3fdd80d12e6b2582ceb Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:23:20 +0100 Subject: [PATCH 1/5] Add enable-unicode option for WIN32 See issue #1419 for details. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcb7062ae..7935e4710 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ option ( enable-pipewire "compile PipeWire support (if it is available)" on ) option ( enable-readline "compile readline lib line editing (if it is available)" on ) option ( enable-threads "enable multi-threading support (such as parallel voice synthesis)" on ) option ( enable-openmp "enable OpenMP support (parallelization of soundfont decoding, vectorization of voice mixing, etc.)" on ) +option ( enable-unicode "enable UNICODE build for Windows" on ) # Platform specific options if ( CMAKE_SYSTEM MATCHES "Linux" ) @@ -293,7 +294,9 @@ if ( WIN32 OR CYGWIN ) endif() endif () message ( STATUS "Targeting Windows Version ${windows-version}" ) - add_definitions ( -D _UNICODE -D UNICODE ) + if ( enable-unicode ) + add_definitions ( -D _UNICODE -D UNICODE ) + endif () add_definitions ( -D _WIN32_WINNT=${windows-version} ) add_definitions ( -D WINVER=${windows-version} ) list ( APPEND CMAKE_REQUIRED_DEFINITIONS "-DWINVER=${windows-version}" ) From bb6433d7f0cbb103b79f53f5507a193ca20ac220 Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:24:46 +0100 Subject: [PATCH 2/5] Fix unicode support for CYGWIN See issue #1419 for details. --- src/drivers/fluid_waveout.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/drivers/fluid_waveout.c b/src/drivers/fluid_waveout.c index 039295f4f..5fe41c7b3 100644 --- a/src/drivers/fluid_waveout.c +++ b/src/drivers/fluid_waveout.c @@ -427,8 +427,11 @@ new_fluid_waveout_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t f if(res == MMSYSERR_NOERROR) { #ifdef _UNICODE - +#ifdef __CYGWIN__ + if(wcscasecmp(lpwDevName, caps.szPname) == 0) +#else if(wcsicmp(lpwDevName, caps.szPname) == 0) +#endif #else if(FLUID_STRCASECMP(dev_name, caps.szPname) == 0) #endif From 8d5b16f853668086260b7fbe78ceb1a26d0fa7f4 Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:25:40 +0100 Subject: [PATCH 3/5] winmidi: Fix warning about sign mismatch. See issue #1419 for details. --- src/drivers/fluid_winmidi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index 1157d7f10..2f5eefebe 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -481,8 +481,9 @@ fluid_winmidi_parse_device_name(fluid_winmidi_driver_t *dev, char *dev_name) static void fluid_winmidi_autoconnect_build_name(char *name) { char new_name[MAXPNAMELEN] = { 0 }; - int i, j, n = 0; - int num = midiInGetNumDevs(); + int j; + unsigned int i, n = 0; + unsigned int num = midiInGetNumDevs(); for (i = 0; i < num; ++i) { From 4bda2650ac43ed49757e1e519cc44636aefb9bc1 Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:26:23 +0100 Subject: [PATCH 4/5] Fix C90 error with fluid_get_windows_error() See issue #1419 for details. --- src/utils/fluid_sys.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index e8620b3c8..9b24e56d7 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -1787,9 +1787,16 @@ fluid_long_long_t fluid_file_tell(FILE* f) #if defined(_WIN32) || defined(__CYGWIN__) // not thread-safe! +#define FLUID_WINDOWS_MEX_ERROR_LEN 1024 + char* fluid_get_windows_error(void) { - static TCHAR err[1024]; +#ifdef _UNICODE + TCHAR err[FLUID_WINDOWS_MEX_ERROR_LEN]; + static char ascii_err[FLUID_WINDOWS_MEX_ERROR_LEN]; +#else + static TCHAR err[FLUID_WINDOWS_MEX_ERROR_LEN]; +#endif FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -1800,8 +1807,6 @@ char* fluid_get_windows_error(void) NULL); #ifdef _UNICODE - static char ascii_err[sizeof(err)]; - WideCharToMultiByte(CP_UTF8, 0, err, -1, ascii_err, sizeof(ascii_err)/sizeof(ascii_err[0]), 0, 0); return ascii_err; #else From ada6ece737c05141fc137fdcec1905ce19b679ce Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:28:33 +0100 Subject: [PATCH 5/5] Windows: Fix unicode support with libsndfile See issue #1422 for details. --- src/utils/fluid_sys.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index cefff4a0a..0672baefd 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -156,6 +156,12 @@ typedef gintptr intptr_t; #pragma warning(disable : 4996) #endif +/* + * Required by Windows-specific sf_wchar_open() from + * libsndfile that takes a UTF16_BE encoded filename. + */ +#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 + #endif /* Darwin special defines (taken from config_macosx.h) */