1- From d7fd69a91c5293c18103f8b11a61d74f55c055c2 Mon Sep 17 00:00:00 2001
2- 1+ From 4edd86332c57377c74a3694129ba9efb91ad82d9 Mon Sep 17 00:00:00 2001
2+ From: Ghabry
33Date: Fri, 17 Mar 2023 14:00:45 +0100
44Subject: [PATCH 1/2] Shim glib
55
66---
77 CMakeLists.txt | 4 +-
88 src/CMakeLists.txt | 3 +-
9- src/bindings/fluid_cmd.c | 3 ++
10- src/glib_shim.c | 12 +++++
11- src/glib_shim.h | 90 ++++++++++++++++++++++++++++++++
9+ src/bindings/fluid_cmd.c | 3 +
10+ src/glib_shim.c | 12 ++++
11+ src/glib_shim.h | 95 ++++++++++++++++++++++++++++++++
1212 src/rvoice/fluid_rvoice_mixer.c | 10 ----
1313 src/sfloader/fluid_defsfont.c | 5 --
1414 src/sfloader/fluid_samplecache.c | 2 +
15+ src/sfloader/fluid_sffile.c | 6 +-
1516 src/synth/fluid_synth.c | 16 +++---
1617 src/synth/fluid_synth.h | 2 +-
17- src/utils/fluid_sys.c | 9 +++ -
18+ src/utils/fluid_sys.c | 9 ++-
1819 src/utils/fluid_sys.h | 8 +--
1920 src/utils/fluidsynth_priv.h | 2 +-
20- 13 files changed, 132 insertions(+), 34 deletions(-)
21+ 14 files changed, 142 insertions(+), 35 deletions(-)
2122 create mode 100644 src/glib_shim.c
2223 create mode 100644 src/glib_shim.h
2324
2425diff --git a/CMakeLists.txt b/CMakeLists.txt
25- index 849f8b37..d86b9bc0 100644
26+ index 849f8b3..d86b9bc 100644
2627--- a/CMakeLists.txt
2728+++ b/CMakeLists.txt
2829@@ -533,8 +533,8 @@ if ( CMAKE_VERSION VERSION_GREATER_EQUAL 3.15 AND VCPKG_TOOLCHAIN )
@@ -37,7 +38,7 @@ index 849f8b37..d86b9bc0 100644
3738 if ( GLib2_VERSION AND GLib2_VERSION VERSION_LESS "2.26.0" )
3839 message ( WARNING "Your version of glib is very old. This may cause problems with fluidsynth's sample cache on Windows. Consider updating to glib 2.26 or newer!" )
3940diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
40- index a2f9e55b..e2a1d752 100644
41+ index a2f9e55..e2a1d75 100644
4142--- a/src/CMakeLists.txt
4243+++ b/src/CMakeLists.txt
4344@@ -108,6 +108,7 @@ endif ( OBOE_SUPPORT )
@@ -58,7 +59,7 @@ index a2f9e55b..e2a1d752 100644
5859 if ( TARGET SndFile::sndfile AND LIBSNDFILE_SUPPORT )
5960 target_link_libraries ( libfluidsynth-OBJ PUBLIC SndFile::sndfile )
6061diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c
61- index 444b2635..74780e14 100644
62+ index 444b263..74780e1 100644
6263--- a/src/bindings/fluid_cmd.c
6364+++ b/src/bindings/fluid_cmd.c
6465@@ -433,6 +433,8 @@ static const fluid_cmd_t fluid_commands[] =
@@ -80,7 +81,7 @@ index 444b2635..74780e14 100644
8081 /**
8182diff --git a/src/glib_shim.c b/src/glib_shim.c
8283new file mode 100644
83- index 00000000..40b8b560
84+ index 0000000..40b8b56
8485--- /dev/null
8586+++ b/src/glib_shim.c
8687@@ -0,0 +1,12 @@
@@ -98,10 +99,10 @@ index 00000000..40b8b560
9899+ }
99100diff --git a/src/glib_shim.h b/src/glib_shim.h
100101new file mode 100644
101- index 00000000..f90f0eb4
102+ index 0000000..08582e3
102103--- /dev/null
103104+++ b/src/glib_shim.h
104- @@ -0,0 +1,90 @@
105+ @@ -0,0 +1,95 @@
105106+ #ifndef GLIB_SHIM_H
106107+ #define GLIB_SHIM_H
107108+
@@ -132,8 +133,13 @@ index 00000000..f90f0eb4
132133+ #define G_BIG_ENDIAN 1
133134+ #endif
134135+
136+ + #ifdef WORDS_BIGENDIAN
137+ + #define GINT32_FROM_LE(x) ((x >> 24) | ((x<<8) & 0x00FF0000) | ((x>>8) & 0x0000FF00) | (x << 24))
138+ + #define GINT16_FROM_LE(x) ((x >> 8) | (x << 8))
139+ + #else
135140+ #define GINT32_FROM_LE(x) ((x))
136141+ #define GINT16_FROM_LE(x) ((x))
142+ + #endif
137143+
138144+ #define G_LIKELY
139145+ #define G_UNLIKELY
@@ -193,7 +199,7 @@ index 00000000..f90f0eb4
193199+
194200+ #endif
195201diff --git a/src/rvoice/fluid_rvoice_mixer.c b/src/rvoice/fluid_rvoice_mixer.c
196- index c1e2fb2e..92553131 100644
202+ index c1e2fb2..9255313 100644
197203--- a/src/rvoice/fluid_rvoice_mixer.c
198204+++ b/src/rvoice/fluid_rvoice_mixer.c
199205@@ -478,7 +478,6 @@ fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t *buffers,
@@ -249,7 +255,7 @@ index c1e2fb2e..92553131 100644
249255 {
250256 int dsp_i = i * FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE + j;
251257diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c
252- index b601621e..a82362d3 100644
258+ index b601621..a82362d 100644
253259--- a/src/sfloader/fluid_defsfont.c
254260+++ b/src/sfloader/fluid_defsfont.c
255261@@ -395,8 +395,6 @@ int fluid_defsfont_load_all_sampledata(fluid_defsfont_t *defsfont, SFData *sfdat
@@ -282,7 +288,7 @@ index b601621e..a82362d3 100644
282288 int modified;
283289 /* Data pointers of SF2 samples point to large sample data block loaded above */
284290diff --git a/src/sfloader/fluid_samplecache.c b/src/sfloader/fluid_samplecache.c
285- index 64e9e9e7..4c504c0f 100644
291+ index 64e9e9e..4c504c0 100644
286292--- a/src/sfloader/fluid_samplecache.c
287293+++ b/src/sfloader/fluid_samplecache.c
288294@@ -282,6 +282,7 @@ static fluid_samplecache_entry_t *get_samplecache_entry(SFData *sf,
@@ -301,8 +307,28 @@ index 64e9e9e7..4c504c0f 100644
301307 return FLUID_OK;
302308 }
303309
310+ diff --git a/src/sfloader/fluid_sffile.c b/src/sfloader/fluid_sffile.c
311+ index 8359424..2aae4db 100644
312+ --- a/src/sfloader/fluid_sffile.c
313+ +++ b/src/sfloader/fluid_sffile.c
314+ @@ -2252,10 +2252,14 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en
315+ if(FLUID_IS_BIG_ENDIAN)
316+ {
317+ unsigned int i;
318+ + unsigned short data;
319+
320+ for(i = 0; i < num_samples; i++)
321+ {
322+ - loaded_data[i] = FLUID_LE16TOH(loaded_data[i]);
323+ + data = loaded_data[i];
324+ + data = (data >> 8) | (data << 8);
325+ + //loaded_data[i] = FLUID_LE16TOH(loaded_data[i]);
326+ + loaded_data[i] = data;
327+ }
328+ }
329+
304330diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c
305- index e356982e..dbfe9002 100644
331+ index e356982..dbfe900 100644
306332--- a/src/synth/fluid_synth.c
307333+++ b/src/synth/fluid_synth.c
308334@@ -636,8 +636,9 @@ new_fluid_synth(fluid_settings_t *settings)
@@ -368,7 +394,7 @@ index e356982e..dbfe9002 100644
368394
369395 FLUID_API_RETURN(1);
370396diff --git a/src/synth/fluid_synth.h b/src/synth/fluid_synth.h
371- index 7dbcdc55..97f51752 100644
397+ index 7dbcdc5..97f5175 100644
372398--- a/src/synth/fluid_synth.h
373399+++ b/src/synth/fluid_synth.h
374400@@ -152,7 +152,7 @@ struct _fluid_synth_t
@@ -381,7 +407,7 @@ index 7dbcdc55..97f51752 100644
381407 fluid_sample_timer_t *sample_timers; /**< List of timers triggered before a block is processed */
382408 unsigned int min_note_length_ticks; /**< If note-offs are triggered just after a note-on, they will be delayed */
383409diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c
384- index babb11ff..e82094be 100644
410+ index babb11f..e82094b 100644
385411--- a/src/utils/fluid_sys.c
386412+++ b/src/utils/fluid_sys.c
387413@@ -33,7 +33,7 @@
@@ -436,7 +462,7 @@ index babb11ff..e82094be 100644
436462 #if OLD_GLIB_THREAD_API
437463
438464diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h
439- index a756fc07..73abd986 100644
465+ index a756fc0..73abd98 100644
440466--- a/src/utils/fluid_sys.h
441467+++ b/src/utils/fluid_sys.h
442468@@ -175,7 +175,7 @@ typedef gintptr intptr_t;
@@ -474,7 +500,7 @@ index a756fc07..73abd986 100644
474500
475501 /* glib prior to 2.32 */
476502diff --git a/src/utils/fluidsynth_priv.h b/src/utils/fluidsynth_priv.h
477- index 67e97abb..9dcfbb76 100644
503+ index 67e97ab..9dcfbb7 100644
478504--- a/src/utils/fluidsynth_priv.h
479505+++ b/src/utils/fluidsynth_priv.h
480506@@ -31,7 +31,7 @@
0 commit comments