Commit 85216966 authored by Max Kellermann's avatar Max Kellermann

decoder/wildmidi: use class Path for the "timidity.cfg" location

parent 1c823e9d
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
#include "WildmidiDecoderPlugin.hxx" #include "WildmidiDecoderPlugin.hxx"
#include "DecoderAPI.hxx" #include "DecoderAPI.hxx"
#include "TagHandler.hxx" #include "TagHandler.hxx"
#include "glib_compat.h" #include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "system/FatalError.hxx"
#include <glib.h> #include <glib.h>
...@@ -37,18 +39,20 @@ static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000; ...@@ -37,18 +39,20 @@ static constexpr unsigned WILDMIDI_SAMPLE_RATE = 48000;
static bool static bool
wildmidi_init(const config_param &param) wildmidi_init(const config_param &param)
{ {
const char *config_file; GError *error = nullptr;
int ret; const Path path = param.GetBlockPath("config_file",
"/etc/timidity/timidity.cfg",
config_file = param.GetBlockValue("config_file", &error);
"/etc/timidity/timidity.cfg"); if (path.IsNull())
if (!g_file_test(config_file, G_FILE_TEST_IS_REGULAR)) { FatalError(error);
g_debug("configuration file does not exist: %s", config_file);
if (!FileExists(path)) {
const auto utf8 = path.ToUTF8();
g_debug("configuration file does not exist: %s", utf8.c_str());
return false; return false;
} }
ret = WildMidi_Init(config_file, WILDMIDI_SAMPLE_RATE, 0); return WildMidi_Init(path.c_str(), WILDMIDI_SAMPLE_RATE, 0) == 0;
return ret == 0;
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment