Module: wine Branch: master Commit: 839fb09bf01bb7e131ec994621e55125313a4705 URL: https://gitlab.winehq.org/wine/wine/-/commit/839fb09bf01bb7e131ec994621e5512...
Author: Alexandre Julliard julliard@winehq.org Date: Sat Feb 17 22:37:28 2024 +0100
fluidsynth: Import upstream release 2.3.4.
---
libs/fluidsynth/include/fluidsynth/version.h | 4 +-- libs/fluidsynth/src/midi/fluid_midi.c | 24 +++++++++++++++ libs/fluidsynth/src/utils/fluid_sys.c | 46 ++++++++++++++++------------ 3 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/libs/fluidsynth/include/fluidsynth/version.h b/libs/fluidsynth/include/fluidsynth/version.h index 2de6e9fbf4d..96ee8183bd3 100644 --- a/libs/fluidsynth/include/fluidsynth/version.h +++ b/libs/fluidsynth/include/fluidsynth/version.h @@ -31,10 +31,10 @@ extern "C" { * * @{ */ -#define FLUIDSYNTH_VERSION "2.3.3" /**< String constant of libfluidsynth version. */ +#define FLUIDSYNTH_VERSION "2.3.4" /**< String constant of libfluidsynth version. */ #define FLUIDSYNTH_VERSION_MAJOR 2 /**< libfluidsynth major version integer constant. */ #define FLUIDSYNTH_VERSION_MINOR 3 /**< libfluidsynth minor version integer constant. */ -#define FLUIDSYNTH_VERSION_MICRO 3 /**< libfluidsynth micro version integer constant. */ +#define FLUIDSYNTH_VERSION_MICRO 4 /**< libfluidsynth micro version integer constant. */
FLUIDSYNTH_API void fluid_version(int *major, int *minor, int *micro); FLUIDSYNTH_API char* fluid_version_str(void); diff --git a/libs/fluidsynth/src/midi/fluid_midi.c b/libs/fluidsynth/src/midi/fluid_midi.c index 6ea0216cfb3..dc6f0b865f3 100644 --- a/libs/fluidsynth/src/midi/fluid_midi.c +++ b/libs/fluidsynth/src/midi/fluid_midi.c @@ -1641,6 +1641,23 @@ fluid_player_handle_reset_synth(void *data, const char *name, int value) player->reset_synth_between_songs = value; }
+static int check_for_on_notes(fluid_synth_t *synth) +{ + fluid_voice_t* v[1024]; + int i, res=FALSE; + fluid_synth_get_voicelist(synth, v, FLUID_N_ELEMENTS(v), -1); + for(i=0; i<FLUID_N_ELEMENTS(v) && v[i] != NULL; i++) + { + fluid_voice_t *vv = v[i]; + if(vv != NULL && fluid_voice_is_on(vv)) + { + res = TRUE; + FLUID_LOG(FLUID_DBG, "Voice is on! channel %d, key %d", fluid_voice_get_channel(vv), fluid_voice_get_key(vv)); + } + } + return res; +} + /** * Create a new MIDI player. * @param synth Fluid synthesizer instance to create player for @@ -2197,10 +2214,16 @@ fluid_player_callback(void *data, unsigned int msec) /* The first time we notice we've run out of MIDI events but there are still active voices, disable all hold pedals */ if(!player->end_pedals_disabled) { + if(check_for_on_notes(synth)) + { + FLUID_LOG(FLUID_WARN, "End of the MIDI file reached, but not all notes have received a note off event! OFFing them now! Run with --verbose to spot pending voices."); + } + for(i = 0; i < synth->midi_channels; i++) { fluid_synth_cc(player->synth, i, SUSTAIN_SWITCH, 0); fluid_synth_cc(player->synth, i, SOSTENUTO_SWITCH, 0); + fluid_synth_cc(player->synth, i, ALL_NOTES_OFF, 0); }
player->end_pedals_disabled = 1; @@ -2268,6 +2291,7 @@ fluid_player_play(fluid_player_t *player) if(!player->use_system_timer) { fluid_sample_timer_reset(player->synth, player->sample_timer); + player->cur_msec = 0; }
/* If we're at the end of the playlist and there are no loops left, loop once */ diff --git a/libs/fluidsynth/src/utils/fluid_sys.c b/libs/fluidsynth/src/utils/fluid_sys.c index 0f8e6a608fc..8fc14cd5f5e 100644 --- a/libs/fluidsynth/src/utils/fluid_sys.c +++ b/libs/fluidsynth/src/utils/fluid_sys.c @@ -1606,12 +1606,12 @@ fluid_server_socket_t * new_fluid_server_socket(int port, fluid_server_func_t func, void *data) { fluid_server_socket_t *server_socket; + struct sockaddr_in addr4; #ifdef IPV6_SUPPORT - struct sockaddr_in6 addr; -#else - struct sockaddr_in addr; + struct sockaddr_in6 addr6; #endif - + const struct sockaddr *addr; + size_t addr_size; fluid_socket_t sock;
fluid_return_val_if_fail(func != NULL, NULL); @@ -1621,23 +1621,37 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data) return NULL; }
+ FLUID_MEMSET(&addr4, 0, sizeof(addr4)); + addr4.sin_family = AF_INET; + addr4.sin_port = htons((uint16_t)port); + addr4.sin_addr.s_addr = htonl(INADDR_ANY); + +#ifdef IPV6_SUPPORT + FLUID_MEMSET(&addr6, 0, sizeof(addr6)); + addr6.sin6_family = AF_INET6; + addr6.sin6_port = htons((uint16_t)port); + addr6.sin6_addr = in6addr_any; +#endif + #ifdef IPV6_SUPPORT sock = socket(AF_INET6, SOCK_STREAM, 0); + addr = (const struct sockaddr *) &addr6; + addr_size = sizeof(addr6);
if(sock == INVALID_SOCKET) { - FLUID_LOG(FLUID_ERR, "Failed to create server socket: %d", fluid_socket_get_error()); - fluid_socket_cleanup(); - return NULL; + FLUID_LOG(FLUID_WARN, "Failed to create IPv6 server socket: %d (will try with IPv4)", fluid_socket_get_error()); + + sock = socket(AF_INET, SOCK_STREAM, 0); + addr = (const struct sockaddr *) &addr4; + addr_size = sizeof(addr4); }
- FLUID_MEMSET(&addr, 0, sizeof(addr)); - addr.sin6_family = AF_INET6; - addr.sin6_port = htons((uint16_t)port); - addr.sin6_addr = in6addr_any; #else - sock = socket(AF_INET, SOCK_STREAM, 0); + addr = (const struct sockaddr *) &addr4; + addr_size = sizeof(addr4); +#endif
if(sock == INVALID_SOCKET) { @@ -1646,13 +1660,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data) return NULL; }
- FLUID_MEMSET(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons((uint16_t)port); - addr.sin_addr.s_addr = htonl(INADDR_ANY); -#endif - - if(bind(sock, (const struct sockaddr *) &addr, sizeof(addr)) == SOCKET_ERROR) + if(bind(sock, addr, addr_size) == SOCKET_ERROR) { FLUID_LOG(FLUID_ERR, "Failed to bind server socket: %d", fluid_socket_get_error()); fluid_socket_close(sock);