decoder/mpcdec: convert to C++

This commit is contained in:
Max Kellermann 2013-07-28 13:04:12 +02:00
parent 2eed9d64ce
commit f016a99f24
4 changed files with 46 additions and 12 deletions

View File

@ -510,7 +510,9 @@ libdecoder_plugins_a_SOURCES += \
endif endif
if HAVE_MPCDEC if HAVE_MPCDEC
libdecoder_plugins_a_SOURCES += src/decoder/mpcdec_decoder_plugin.c libdecoder_plugins_a_SOURCES += \
src/decoder/MpcdecDecoderPlugin.cxx \
src/decoder/MpcdecDecoderPlugin.hxx
endif endif
if HAVE_OPUS if HAVE_OPUS

View File

@ -40,12 +40,12 @@
#include "decoder/WildmidiDecoderPlugin.hxx" #include "decoder/WildmidiDecoderPlugin.hxx"
#include "decoder/MikmodDecoderPlugin.hxx" #include "decoder/MikmodDecoderPlugin.hxx"
#include "decoder/ModplugDecoderPlugin.hxx" #include "decoder/ModplugDecoderPlugin.hxx"
#include "decoder/MpcdecDecoderPlugin.hxx"
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
extern const struct decoder_plugin mpcdec_decoder_plugin;
extern const struct decoder_plugin sidplay_decoder_plugin; extern const struct decoder_plugin sidplay_decoder_plugin;
extern const struct decoder_plugin fluidsynth_decoder_plugin; extern const struct decoder_plugin fluidsynth_decoder_plugin;

View File

@ -18,6 +18,7 @@
*/ */
#include "config.h" #include "config.h"
#include "MpcdecDecoderPlugin.hxx"
#include "decoder_api.h" #include "decoder_api.h"
#include "audio_check.h" #include "audio_check.h"
#include "tag_handler.h" #include "tag_handler.h"
@ -62,7 +63,7 @@ mpc_seek_cb(cb_first_arg, mpc_int32_t offset)
{ {
struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data; struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data;
return input_stream_lock_seek(data->is, offset, SEEK_SET, NULL); return input_stream_lock_seek(data->is, offset, SEEK_SET, nullptr);
} }
static mpc_int32_t static mpc_int32_t
@ -144,7 +145,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
#endif #endif
mpc_reader reader; mpc_reader reader;
mpc_streaminfo info; mpc_streaminfo info;
GError *error = NULL; GError *error = nullptr;
struct audio_format audio_format; struct audio_format audio_format;
struct mpc_decoder_data data; struct mpc_decoder_data data;
@ -185,7 +186,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
} }
#else #else
demux = mpc_demux_init(&reader); demux = mpc_demux_init(&reader);
if (demux == NULL) { if (demux == nullptr) {
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP)
g_warning("Not a valid musepack stream"); g_warning("Not a valid musepack stream");
return; return;
@ -296,7 +297,7 @@ mpcdec_get_file_duration(struct input_stream *is)
struct mpc_decoder_data data; struct mpc_decoder_data data;
data.is = is; data.is = is;
data.decoder = NULL; data.decoder = nullptr;
reader.read = mpc_read_cb; reader.read = mpc_read_cb;
reader.seek = mpc_seek_cb; reader.seek = mpc_seek_cb;
@ -312,7 +313,7 @@ mpcdec_get_file_duration(struct input_stream *is)
return -1; return -1;
#else #else
demux = mpc_demux_init(&reader); demux = mpc_demux_init(&reader);
if (demux == NULL) if (demux == nullptr)
return -1; return -1;
mpc_demux_get_info(demux, &info); mpc_demux_get_info(demux, &info);
@ -337,11 +338,17 @@ mpcdec_scan_stream(struct input_stream *is,
return true; return true;
} }
static const char *const mpcdec_suffixes[] = { "mpc", NULL }; static const char *const mpcdec_suffixes[] = { "mpc", nullptr };
const struct decoder_plugin mpcdec_decoder_plugin = { const struct decoder_plugin mpcdec_decoder_plugin = {
.name = "mpcdec", "mpcdec",
.stream_decode = mpcdec_decode, nullptr,
.scan_stream = mpcdec_scan_stream, nullptr,
.suffixes = mpcdec_suffixes, mpcdec_decode,
nullptr,
nullptr,
mpcdec_scan_stream,
nullptr,
mpcdec_suffixes,
nullptr,
}; };

View File

@ -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_MPCDEC_HXX
#define MPD_DECODER_MPCDEC_HXX
extern const struct decoder_plugin mpcdec_decoder_plugin;
#endif