aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/FluidsynthDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-27 22:31:24 +0200
committerMax Kellermann <max@duempel.org>2013-10-02 08:57:55 +0200
commit060814daa83f6a94f5934464ae42a406c5c7e947 (patch)
treef636ec6cdbb8e52fda6db987d2a28fc73c7b94b4 /src/decoder/FluidsynthDecoderPlugin.cxx
parentc53492a76a8a05825e1c7f699c05645eee891199 (diff)
downloadmpd-060814daa83f6a94f5934464ae42a406c5c7e947.tar.gz
mpd-060814daa83f6a94f5934464ae42a406c5c7e947.tar.xz
mpd-060814daa83f6a94f5934464ae42a406c5c7e947.zip
Log: new logging library API
Prepare to migrate away from GLib. Currently, we're still using GLib as a backend.
Diffstat (limited to '')
-rw-r--r--src/decoder/FluidsynthDecoderPlugin.cxx32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx
index 4db4f1618..99f1598c8 100644
--- a/src/decoder/FluidsynthDecoderPlugin.cxx
+++ b/src/decoder/FluidsynthDecoderPlugin.cxx
@@ -22,13 +22,14 @@
#include "DecoderAPI.hxx"
#include "CheckAudioFormat.hxx"
#include "util/Error.hxx"
+#include "util/Domain.hxx"
+#include "Log.hxx"
#include <glib.h>
#include <fluidsynth.h>
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "fluidsynth"
+static constexpr Domain fluidsynth_domain("fluidsynth");
static unsigned sample_rate;
static const char *soundfont_path;
@@ -36,27 +37,27 @@ static const char *soundfont_path;
/**
* Convert a fluidsynth log level to a GLib log level.
*/
-static GLogLevelFlags
-fluidsynth_level_to_glib(enum fluid_log_level level)
+static LogLevel
+fluidsynth_level_to_mpd(enum fluid_log_level level)
{
switch (level) {
case FLUID_PANIC:
case FLUID_ERR:
- return G_LOG_LEVEL_CRITICAL;
+ return LogLevel::ERROR;
case FLUID_WARN:
- return G_LOG_LEVEL_WARNING;
+ return LogLevel::WARNING;
case FLUID_INFO:
- return G_LOG_LEVEL_INFO;
+ return LogLevel::INFO;
case FLUID_DBG:
case LAST_LOG_LEVEL:
- return G_LOG_LEVEL_DEBUG;
+ return LogLevel::DEBUG;
}
/* invalid fluidsynth log level */
- return G_LOG_LEVEL_MESSAGE;
+ return LogLevel::INFO;
}
/**
@@ -66,8 +67,9 @@ fluidsynth_level_to_glib(enum fluid_log_level level)
static void
fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
{
- g_log(G_LOG_DOMAIN, fluidsynth_level_to_glib(fluid_log_level(level)),
- "%s", message);
+ Log(fluidsynth_domain,
+ fluidsynth_level_to_mpd(fluid_log_level(level)),
+ message);
}
static bool
@@ -77,7 +79,7 @@ fluidsynth_init(const config_param &param)
sample_rate = param.GetBlockValue("sample_rate", 48000u);
if (!audio_check_sample_rate(sample_rate, error)) {
- g_warning("%s", error.GetMessage());
+ LogError(error);
return false;
}
@@ -125,7 +127,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
ret = fluid_synth_sfload(synth, soundfont_path, true);
if (ret < 0) {
- g_warning("fluid_synth_sfload() failed");
+ LogWarning(fluidsynth_domain, "fluid_synth_sfload() failed");
delete_fluid_synth(synth);
delete_fluid_settings(settings);
return;
@@ -142,7 +144,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
ret = fluid_player_add(player, path_fs);
if (ret != 0) {
- g_warning("fluid_player_add() failed");
+ LogWarning(fluidsynth_domain, "fluid_player_add() failed");
delete_fluid_player(player);
delete_fluid_synth(synth);
delete_fluid_settings(settings);
@@ -153,7 +155,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
ret = fluid_player_play(player);
if (ret != 0) {
- g_warning("fluid_player_play() failed");
+ LogWarning(fluidsynth_domain, "fluid_player_play() failed");
delete_fluid_player(player);
delete_fluid_synth(synth);
delete_fluid_settings(settings);