Use internal log function for Fluidsynth
Some checks failed
Build / download-system-deps (push) Successful in 1m15s
Build / build-gentoo (push) Successful in 1m34s
Build / get-source-code (push) Successful in 4m5s
Build / build-deb (push) Failing after 2m37s
Build / build-appimage (push) Successful in 1m26s
Build / build-android (push) Failing after 16s
Build / build-windows (push) Failing after 4m11s

This commit is contained in:
Zachary Hall 2024-12-29 09:19:33 -08:00
parent 3fd1a3ca42
commit 6920d3c0ff

View file

@ -10,7 +10,21 @@
#include <util.hpp> #include <util.hpp>
#include <filesystem> #include <filesystem>
#include <limits.h> #include <limits.h>
#include <log.hpp>
namespace fs = std::filesystem; namespace fs = std::filesystem;
using Looper::Log::LogStream;
static void log_fn(int level, const char *msg, void *data) {
LogStream *stream;
switch (level) {
case FLUID_ERR:
case FLUID_PANIC: stream = &ERROR; break;
case FLUID_WARN: stream = &WARNING; break;
default:
case FLUID_INFO: stream = &INFO; break;
case FLUID_DBG: stream = &DEBUG; break;
}
stream->writeln(msg);
}
void FluidSynthBackend::fluidsynth_get_property_list_wrapper(void *udata, const char *name, int type) { void FluidSynthBackend::fluidsynth_get_property_list_wrapper(void *udata, const char *name, int type) {
((FluidSynthBackend*)udata)->fluidsynth_get_property_list(name, type); ((FluidSynthBackend*)udata)->fluidsynth_get_property_list(name, type);
} }
@ -48,11 +62,20 @@ void FluidSynthBackend::fluidsynth_get_property_list(const char *name, int type)
property.set_id(PropertyId::BackendSpecific); property.set_id(PropertyId::BackendSpecific);
fluidsynth_properties.push_back(property); fluidsynth_properties.push_back(property);
} }
static bool log_fn_registered = false;
std::vector<Property> FluidSynthBackend::get_property_list() { std::vector<Property> FluidSynthBackend::get_property_list() {
return fluidsynth_properties; return fluidsynth_properties;
} }
void FluidSynthBackend::load(const char *filename) { void FluidSynthBackend::load(const char *filename) {
memset(&spec, 0, sizeof(spec)); memset(&spec, 0, sizeof(spec));
if (!log_fn_registered) {
fluid_set_log_function(FLUID_PANIC, &log_fn, nullptr);
fluid_set_log_function(FLUID_ERR, &log_fn, nullptr);
fluid_set_log_function(FLUID_WARN, &log_fn, nullptr);
fluid_set_log_function(FLUID_INFO, &log_fn, nullptr);
fluid_set_log_function(FLUID_DBG, &log_fn, nullptr);
log_fn_registered = true;
}
current_file = filename; current_file = filename;
spec.format = AUDIO_F32SYS; spec.format = AUDIO_F32SYS;
spec.samples = 100; spec.samples = 100;