aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-10 18:18:14 +0100
committerMax Kellermann <max@duempel.org>2013-01-10 18:18:14 +0100
commit3dd38e7b7f7292caf91675a48076f7bba40ed309 (patch)
treef433fc0ce6604974ae94917eef4e0a21b73aab12
parent3711a9765775d584f8e5f94156ce384ad0d3dae7 (diff)
decoder/wavpack: convert to C++
-rw-r--r--Makefile.am4
-rw-r--r--src/decoder/WavpackDecoderPlugin.cxx (renamed from src/decoder/wavpack_decoder_plugin.c)56
-rw-r--r--src/decoder/WavpackDecoderPlugin.hxx25
-rw-r--r--src/decoder_list.c2
-rw-r--r--src/utils.h11
5 files changed, 61 insertions, 37 deletions
diff --git a/Makefile.am b/Makefile.am
index 32ea8aed..e38e9ee7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -544,7 +544,9 @@ libdecoder_plugins_a_SOURCES += \
endif
if HAVE_WAVPACK
-libdecoder_plugins_a_SOURCES += src/decoder/wavpack_decoder_plugin.c
+libdecoder_plugins_a_SOURCES += \
+ src/decoder/WavpackDecoderPlugin.cxx \
+ src/decoder/WavpackDecoderPlugin.hxx
endif
if HAVE_ADPLUG
diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/WavpackDecoderPlugin.cxx
index 0ef807e0..fdd910c8 100644
--- a/src/decoder/wavpack_decoder_plugin.c
+++ b/src/decoder/WavpackDecoderPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 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,9 +18,13 @@
*/
#include "config.h"
+#include "WavpackDecoderPlugin.hxx"
#include "decoder_api.h"
+
+extern "C" {
#include "audio_check.h"
-#include "utils.h"
+}
+
#include "tag_handler.h"
#include "tag_ape.h"
@@ -50,18 +54,18 @@ typedef void (*format_samples_t)(
static void
format_samples_int(int bytes_per_sample, void *buffer, uint32_t count)
{
- int32_t *src = buffer;
+ int32_t *src = (int32_t *)buffer;
switch (bytes_per_sample) {
case 1: {
- int8_t *dst = buffer;
+ int8_t *dst = (int8_t *)buffer;
/*
* The asserts like the following one are because we do the
* formatting of samples within a single buffer. The size
* of the output samples never can be greater than the size
* of the input ones. Otherwise we would have an overflow.
*/
- assert_static(sizeof(*dst) <= sizeof(*src));
+ static_assert(sizeof(*dst) <= sizeof(*src), "Wrong size");
/* pass through and align 8-bit samples */
while (count--) {
@@ -70,8 +74,8 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t count)
break;
}
case 2: {
- uint16_t *dst = buffer;
- assert_static(sizeof(*dst) <= sizeof(*src));
+ uint16_t *dst = (uint16_t *)buffer;
+ static_assert(sizeof(*dst) <= sizeof(*src), "Wrong size");
/* pass through and align 16-bit samples */
while (count--) {
@@ -94,7 +98,7 @@ static void
format_samples_float(G_GNUC_UNUSED int bytes_per_sample, void *buffer,
uint32_t count)
{
- float *p = buffer;
+ float *p = (float *)buffer;
while (count--) {
*p /= (1 << 23);
@@ -356,7 +360,7 @@ static struct wavpack_input *
wpin(void *id)
{
assert(id);
- return id;
+ return (struct wavpack_input *)id;
}
static int32_t
@@ -438,14 +442,14 @@ wavpack_input_can_seek(void *id)
}
static WavpackStreamReader mpd_is_reader = {
- .read_bytes = wavpack_input_read_bytes,
- .get_pos = wavpack_input_get_pos,
- .set_pos_abs = wavpack_input_set_pos_abs,
- .set_pos_rel = wavpack_input_set_pos_rel,
- .push_back_byte = wavpack_input_push_back_byte,
- .get_length = wavpack_input_get_length,
- .can_seek = wavpack_input_can_seek,
- .write_bytes = NULL /* no need to write edited tags */
+ wavpack_input_read_bytes,
+ wavpack_input_get_pos,
+ wavpack_input_set_pos_abs,
+ wavpack_input_set_pos_rel,
+ wavpack_input_push_back_byte,
+ wavpack_input_get_length,
+ wavpack_input_can_seek,
+ nullptr /* no need to write edited tags */
};
static void
@@ -472,7 +476,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
* single files. utf8url is not absolute file path :/
*/
if (uri == NULL)
- return false;
+ return nullptr;
wvc_url = g_strconcat(uri, "c", NULL);
is_wvc = input_stream_open(wvc_url, mutex, cond, NULL);
@@ -584,10 +588,14 @@ static char const *const wavpack_mime_types[] = {
};
const struct decoder_plugin wavpack_decoder_plugin = {
- .name = "wavpack",
- .stream_decode = wavpack_streamdecode,
- .file_decode = wavpack_filedecode,
- .scan_file = wavpack_scan_file,
- .suffixes = wavpack_suffixes,
- .mime_types = wavpack_mime_types
+ "wavpack",
+ nullptr,
+ nullptr,
+ wavpack_streamdecode,
+ wavpack_filedecode,
+ wavpack_scan_file,
+ nullptr,
+ nullptr,
+ wavpack_suffixes,
+ wavpack_mime_types
};
diff --git a/src/decoder/WavpackDecoderPlugin.hxx b/src/decoder/WavpackDecoderPlugin.hxx
new file mode 100644
index 00000000..9ebe6354
--- /dev/null
+++ b/src/decoder/WavpackDecoderPlugin.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_WAVPACK_HXX
+#define MPD_DECODER_WAVPACK_HXX
+
+extern const struct decoder_plugin wavpack_decoder_plugin;
+
+#endif
diff --git a/src/decoder_list.c b/src/decoder_list.c
index 79e03a4e..9320f34e 100644
--- a/src/decoder_list.c
+++ b/src/decoder_list.c
@@ -30,6 +30,7 @@
#include "decoder/OpusDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h"
+#include "decoder/WavpackDecoderPlugin.hxx"
#include <glib.h>
@@ -42,7 +43,6 @@ extern const struct decoder_plugin audiofile_decoder_plugin;
extern const struct decoder_plugin mp4ff_decoder_plugin;
extern const struct decoder_plugin faad_decoder_plugin;
extern const struct decoder_plugin mpcdec_decoder_plugin;
-extern const struct decoder_plugin wavpack_decoder_plugin;
extern const struct decoder_plugin modplug_decoder_plugin;
extern const struct decoder_plugin mikmod_decoder_plugin;
extern const struct decoder_plugin sidplay_decoder_plugin;
diff --git a/src/utils.h b/src/utils.h
index ba7307de..059d44fa 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -22,17 +22,6 @@
#include "gerror.h"
-#include <stdbool.h>
-
-#ifndef assert_static
-/* Compile time assertion developed by Ralf Holly */
-/* http://pera-software.com/articles/compile-time-assertions.pdf */
-#define assert_static(e) \
- do { \
- enum { assert_static__ = 1/(e) }; \
- } while (0)
-#endif /* !assert_static */
-
char *
parsePath(const char *path, GError **error_r);