diff options
author | Max Kellermann <max@duempel.org> | 2013-07-28 13:12:08 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-07-28 13:16:27 +0200 |
commit | 2277d143fa4e407bffa9cb169820c9612ebae7a0 (patch) | |
tree | 48f68c6ff129ae59fb8a01e0788fd9307fdcc5ac /src | |
parent | 6b6d9e64bda0ab19a3f6f13957f6625ba35c1d08 (diff) | |
download | mpd-2277d143fa4e407bffa9cb169820c9612ebae7a0.tar.gz mpd-2277d143fa4e407bffa9cb169820c9612ebae7a0.tar.xz mpd-2277d143fa4e407bffa9cb169820c9612ebae7a0.zip |
decoder/fluidsynth: convert to C++
Diffstat (limited to 'src')
-rw-r--r-- | src/DecoderList.cxx | 2 | ||||
-rw-r--r-- | src/decoder/FluidsynthDecoderPlugin.cxx (renamed from src/decoder/fluidsynth_decoder_plugin.c) | 35 | ||||
-rw-r--r-- | src/decoder/FluidsynthDecoderPlugin.hxx | 25 |
3 files changed, 47 insertions, 15 deletions
diff --git a/src/DecoderList.cxx b/src/DecoderList.cxx index 241997817..a66a21e2f 100644 --- a/src/DecoderList.cxx +++ b/src/DecoderList.cxx @@ -41,13 +41,13 @@ #include "decoder/MikmodDecoderPlugin.hxx" #include "decoder/ModplugDecoderPlugin.hxx" #include "decoder/MpcdecDecoderPlugin.hxx" +#include "decoder/FluidsynthDecoderPlugin.hxx" #include <glib.h> #include <string.h> extern const struct decoder_plugin sidplay_decoder_plugin; -extern const struct decoder_plugin fluidsynth_decoder_plugin; const struct decoder_plugin *const decoder_plugins[] = { #ifdef HAVE_MAD diff --git a/src/decoder/fluidsynth_decoder_plugin.c b/src/decoder/FluidsynthDecoderPlugin.cxx index 894b2d353..da1b41a58 100644 --- a/src/decoder/fluidsynth_decoder_plugin.c +++ b/src/decoder/FluidsynthDecoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2012 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,6 +18,7 @@ */ #include "config.h" +#include "FluidsynthDecoderPlugin.hxx" #include "decoder_api.h" #include "audio_check.h" #include "conf.h" @@ -65,13 +66,14 @@ fluidsynth_level_to_glib(enum fluid_log_level level) static void fluidsynth_mpd_log_function(int level, char *message, G_GNUC_UNUSED void *data) { - g_log(G_LOG_DOMAIN, fluidsynth_level_to_glib(level), "%s", message); + g_log(G_LOG_DOMAIN, fluidsynth_level_to_glib(fluid_log_level(level)), + "%s", message); } static bool fluidsynth_init(const struct config_param *param) { - GError *error = NULL; + GError *error = nullptr; sample_rate = config_get_block_unsigned(param, "sample_rate", 48000); if (!audio_check_sample_rate(sample_rate, &error)) { @@ -85,7 +87,7 @@ fluidsynth_init(const struct config_param *param) "/usr/share/sounds/sf2/FluidR3_GM.sf2"); fluid_set_log_function(LAST_LOG_LEVEL, - fluidsynth_mpd_log_function, NULL); + fluidsynth_mpd_log_function, nullptr); return true; } @@ -107,7 +109,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) /* set up fluid settings */ settings = new_fluid_settings(); - if (settings == NULL) + if (settings == nullptr) return; fluid_settings_setnum(settings, setting_sample_rate, sample_rate); @@ -119,7 +121,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) /* create the fluid synth */ synth = new_fluid_synth(settings); - if (synth == NULL) { + if (synth == nullptr) { delete_fluid_settings(settings); return; } @@ -135,7 +137,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) /* create the fluid player */ player = new_fluid_player(synth); - if (player == NULL) { + if (player == nullptr) { delete_fluid_synth(synth); delete_fluid_settings(settings); return; @@ -181,7 +183,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) if (ret != 0) break; - cmd = decoder_data(decoder, NULL, buffer, sizeof(buffer), + cmd = decoder_data(decoder, nullptr, buffer, sizeof(buffer), 0); if (cmd != DECODE_COMMAND_NONE) break; @@ -207,13 +209,18 @@ fluidsynth_scan_file(const char *file, static const char *const fluidsynth_suffixes[] = { "mid", - NULL + nullptr }; const struct decoder_plugin fluidsynth_decoder_plugin = { - .name = "fluidsynth", - .init = fluidsynth_init, - .file_decode = fluidsynth_file_decode, - .scan_file = fluidsynth_scan_file, - .suffixes = fluidsynth_suffixes, + "fluidsynth", + fluidsynth_init, + nullptr, + nullptr, + fluidsynth_file_decode, + fluidsynth_scan_file, + nullptr, + nullptr, + fluidsynth_suffixes, + nullptr, }; diff --git a/src/decoder/FluidsynthDecoderPlugin.hxx b/src/decoder/FluidsynthDecoderPlugin.hxx new file mode 100644 index 000000000..40ed7e4d8 --- /dev/null +++ b/src/decoder/FluidsynthDecoderPlugin.hxx @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_DECODER_FLUIDSYNTH_HXX +#define MPD_DECODER_FLUIDSYNTH_HXX + +extern const struct decoder_plugin fluidsynth_decoder_plugin; + +#endif |