diff options
author | Max Kellermann <max@duempel.org> | 2013-01-07 22:04:58 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-07 22:04:58 +0100 |
commit | 39060b528aceee15a19842f2e9c830d4b35af99e (patch) | |
tree | 179bff5d1494118f284eb8e45b00206ff7315844 | |
parent | 4a36323f1bf9b6db20faa5f512095d1bb7bced2b (diff) | |
download | mpd-39060b528aceee15a19842f2e9c830d4b35af99e.tar.gz mpd-39060b528aceee15a19842f2e9c830d4b35af99e.tar.xz mpd-39060b528aceee15a19842f2e9c830d4b35af99e.zip |
decoder/vorbis: convert to C++
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | src/decoder/VorbisComments.cxx (renamed from src/decoder/vorbis_comments.c) | 6 | ||||
-rw-r--r-- | src/decoder/VorbisComments.hxx (renamed from src/decoder/vorbis_comments.h) | 6 | ||||
-rw-r--r-- | src/decoder/VorbisDecoderPlugin.cxx (renamed from src/decoder/vorbis_decoder_plugin.c) | 37 | ||||
-rw-r--r-- | src/decoder/VorbisDecoderPlugin.h | 25 | ||||
-rw-r--r-- | src/decoder_list.c | 2 |
6 files changed, 58 insertions, 23 deletions
diff --git a/Makefile.am b/Makefile.am index fb500ed47..557a4180e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -566,9 +566,8 @@ endif if ENABLE_VORBIS_DECODER libdecoder_plugins_a_SOURCES += \ - src/decoder/vorbis_comments.c \ - src/decoder/vorbis_comments.h \ - src/decoder/vorbis_decoder_plugin.c + src/decoder/VorbisComments.cxx src/decoder/VorbisComments.hxx \ + src/decoder/VorbisDecoderPlugin.cxx src/decoder/VorbisDecoderPlugin.h endif if HAVE_FLAC diff --git a/src/decoder/vorbis_comments.c b/src/decoder/VorbisComments.cxx index 84f7c5014..10fe22369 100644 --- a/src/decoder/vorbis_comments.c +++ b/src/decoder/VorbisComments.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,7 +18,7 @@ */ #include "config.h" -#include "vorbis_comments.h" +#include "VorbisComments.hxx" #include "XiphTags.h" #include "tag.h" #include "tag_table.h" @@ -120,7 +120,7 @@ vorbis_scan_comment(const char *comment, for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) if (vorbis_copy_comment(comment, - tag_item_names[i], i, + tag_item_names[i], tag_type(i), handler, handler_ctx)) return; } diff --git a/src/decoder/vorbis_comments.h b/src/decoder/VorbisComments.hxx index c15096930..8212cac47 100644 --- a/src/decoder/vorbis_comments.h +++ b/src/decoder/VorbisComments.hxx @@ -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 @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_VORBIS_COMMENTS_H -#define MPD_VORBIS_COMMENTS_H +#ifndef MPD_VORBIS_COMMENTS_HXX +#define MPD_VORBIS_COMMENTS_HXX #include "check.h" diff --git a/src/decoder/vorbis_decoder_plugin.c b/src/decoder/VorbisDecoderPlugin.cxx index f180a6559..3a05e74a9 100644 --- a/src/decoder/vorbis_decoder_plugin.c +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -18,10 +18,16 @@ */ #include "config.h" -#include "vorbis_comments.h" +#include "VorbisDecoderPlugin.h" +#include "VorbisComments.hxx" +#include "decoder_api.h" + +extern "C" { #include "ogg_codec.h" #include "audio_check.h" #include "uri.h" +} + #include "tag_handler.h" #ifndef HAVE_TREMOR @@ -64,7 +70,7 @@ struct vorbis_input_stream { static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *data) { - struct vorbis_input_stream *vis = data; + struct vorbis_input_stream *vis = (struct vorbis_input_stream *)data; size_t ret = decoder_read(vis->decoder, vis->input_stream, ptr, size * nmemb); @@ -75,7 +81,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *data) static int ogg_seek_cb(void *data, ogg_int64_t offset, int whence) { - struct vorbis_input_stream *vis = data; + struct vorbis_input_stream *vis = (struct vorbis_input_stream *)data; return vis->seekable && (!vis->decoder || decoder_get_command(vis->decoder) != DECODE_COMMAND_STOP) && @@ -91,16 +97,16 @@ static int ogg_close_cb(G_GNUC_UNUSED void *data) static long ogg_tell_cb(void *data) { - const struct vorbis_input_stream *vis = data; + struct vorbis_input_stream *vis = (struct vorbis_input_stream *)data; return (long)vis->input_stream->offset; } static const ov_callbacks vorbis_is_callbacks = { - .read_func = ogg_read_cb, - .seek_func = ogg_seek_cb, - .close_func = ogg_close_cb, - .tell_func = ogg_tell_cb, + ogg_read_cb, + ogg_seek_cb, + ogg_close_cb, + ogg_tell_cb, }; static const char * @@ -343,9 +349,14 @@ static const char *const vorbis_mime_types[] = { }; const struct decoder_plugin vorbis_decoder_plugin = { - .name = "vorbis", - .stream_decode = vorbis_stream_decode, - .scan_stream = vorbis_scan_stream, - .suffixes = vorbis_suffixes, - .mime_types = vorbis_mime_types + "vorbis", + nullptr, + nullptr, + vorbis_stream_decode, + nullptr, + nullptr, + vorbis_scan_stream, + nullptr, + vorbis_suffixes, + vorbis_mime_types }; diff --git a/src/decoder/VorbisDecoderPlugin.h b/src/decoder/VorbisDecoderPlugin.h new file mode 100644 index 000000000..618c9ffde --- /dev/null +++ b/src/decoder/VorbisDecoderPlugin.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2003-2012 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_VORBIS_H +#define MPD_DECODER_VORBIS_H + +extern const struct decoder_plugin vorbis_decoder_plugin; + +#endif diff --git a/src/decoder_list.c b/src/decoder_list.c index 575346c98..79e03a4e6 100644 --- a/src/decoder_list.c +++ b/src/decoder_list.c @@ -28,6 +28,7 @@ #include "decoder/dsf_decoder_plugin.h" #include "decoder/FLACDecoderPlugin.h" #include "decoder/OpusDecoderPlugin.h" +#include "decoder/VorbisDecoderPlugin.h" #include "decoder/AdPlugDecoderPlugin.h" #include <glib.h> @@ -36,7 +37,6 @@ extern const struct decoder_plugin mad_decoder_plugin; extern const struct decoder_plugin mpg123_decoder_plugin; -extern const struct decoder_plugin vorbis_decoder_plugin; extern const struct decoder_plugin sndfile_decoder_plugin; extern const struct decoder_plugin audiofile_decoder_plugin; extern const struct decoder_plugin mp4ff_decoder_plugin; |