COMMON/SWITCH: Update fluidsynth-lite and add Switch support to it

This commit is contained in:
Le Philousophe
2020-03-21 18:21:55 +00:00
parent 2e6ffeffdb
commit 633a27a030
2 changed files with 228 additions and 1 deletions
@@ -7,7 +7,7 @@ HELPERS_DIR=$PACKAGE_DIR/../..
do_make_bdir
do_http_fetch fluidsynth-lite \
'https://github.com/Doom64/fluidsynth-lite/archive/38353444676a1788ef78eb7f835fba4fa061f3f2.tar.gz' 'tar xzf'
'https://github.com/Doom64/fluidsynth-lite/archive/c539a8d9270ba5a3f7d6e460606483fc2ab1eb61.tar.gz' 'tar xzf'
# -DCMAKE_SYSTEM_NAME=Windows for Windows
@@ -0,0 +1,227 @@
diff --git a/src/config_switch.h b/src/config_switch.h
new file mode 100644
index 0000000..06ba820
--- /dev/null
+++ b/src/config_switch.h
@@ -0,0 +1,157 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* Define to enable ALSA driver */
+// #define ALSA_SUPPORT 0
+
+/* Define to activate sound output to files */
+// #define AUFILE_SUPPORT 0
+
+/* whether or not we are supporting CoreAudio */
+// #define COREAUDIO_SUPPORT 0
+
+/* whether or not we are supporting CoreMIDI */
+// #define COREMIDI_SUPPORT 0
+
+/* whether or not we are supporting DART */
+// #define DART_SUPPORT 0
+
+/* Define if building for Mac OS X Darwin */
+// #define DARWIN 0
+
+/* Define if D-Bus support is enabled */
+// #define DBUS_SUPPORT 0
+
+/* Soundfont to load automatically in some use cases */
+#define DEFAULT_SOUNDFONT "/switch/default.sf2"
+
+/* Define to enable FPE checks */
+// #define FPE_CHECK 0
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+// #define HAVE_DLFCN_H 0
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* whether or not we are supporting ladcca */
+// #define HAVE_LADCCA 0
+
+/* whether or not we are supporting lash */
+// #define HAVE_LASH 0
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+// #define HAVE_LIBDL 0
+
+/* Define to 1 if you have the `MidiShare' library (-lMidiShare). */
+// #define HAVE_LIBMIDISHARE 0
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <math.h> header file. */
+#define HAVE_MATH_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#define HAVE_NETINET_TCP_H 1
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdbool.h> header file. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdatomic.h> header file. */
+#define HAVE_STDATOMIC_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <threads.h> header file. */
+#define HAVE_THREADS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Name of package */
+#define PACKAGE "fluidsynth"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "switch-fluidsynth-lite"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "switch-fluidsynth-lite-1.1.6-nx"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME @PACKAGE_TARNAME@
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION @PACKAGE_VERSION@
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "1.1.6"
+
+/* Define to do all DSP in single floating point precision */
+#define WITH_FLOAT 1
+
+/* Define if the compiler supports VLA */
+#define SUPPORTS_VLA 1
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef inline
+#define inline __inline
+#endif
+
+#endif /* CONFIG_H */
diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c
index 9976f00..6829afc 100644
--- a/src/utils/fluid_sys.c
+++ b/src/utils/fluid_sys.c
@@ -22,6 +22,8 @@
#include <io.h>
#elif defined(__APPLE__)
#include "apple/timing_mach.h"
+#elif defined(__SWITCH__)
+#include <switch.h>
#endif
#include "fluid_sys.h"
@@ -119,6 +121,10 @@ fluid_default_log_function(int level, char* message, void* data)
{
FILE* out;
+#if defined(__SWITCH__) && !defined(NXLINK_DEBUG)
+ return;
+#endif
+
#if defined(WIN32)
out = stdout;
#else
@@ -426,6 +432,15 @@ fluid_thread_self_set_prio (int prio_level)
DosSetPriority (PRTYS_THREAD, PRTYC_REGULAR, PRTYD_MAXIMUM, 0);
}
+#elif defined(__SWITCH__) /* Nintendo Switch specific stuff */
+
+void
+fluid_thread_self_set_prio (int prio_level)
+{
+ u32 nx_priority = (prio_level >= FLUID_SYS_TIMER_HIGH_PRIO_LEVEL) ? 0x2D : 0x3B;
+ svcSetThreadPriority(CUR_THREAD_HANDLE, nx_priority);
+}
+
#else /* POSIX stuff.. Nice POSIX.. Good POSIX. */
void
@@ -651,6 +666,8 @@ new_fluid_thread (const char *name, fluid_thread_func_t func, void *data, int pr
if (detach) {
#if _WIN32
CloseHandle(*thread);
+#elif defined(__SWITCH__)
+ // detach unsupported in libnx
#else
pthread_detach(*thread);
#endif
diff --git a/src/utils/fluidsynth_priv.h b/src/utils/fluidsynth_priv.h
index eeacbbe..e37cf6d 100644
--- a/src/utils/fluidsynth_priv.h
+++ b/src/utils/fluidsynth_priv.h
@@ -34,6 +34,10 @@
#include "config_win32.h"
#endif
+#if defined(__SWITCH__)
+#include "config_switch.h"
+#endif
+
#if HAVE_STRING_H
#include <string.h>
#endif