decoder/vorbis: convert to C++

This commit is contained in:
Max Kellermann 2013-01-07 22:04:58 +01:00
parent 4a36323f1b
commit 39060b528a
6 changed files with 58 additions and 23 deletions

View File

@ -566,9 +566,8 @@ endif
if ENABLE_VORBIS_DECODER if ENABLE_VORBIS_DECODER
libdecoder_plugins_a_SOURCES += \ libdecoder_plugins_a_SOURCES += \
src/decoder/vorbis_comments.c \ src/decoder/VorbisComments.cxx src/decoder/VorbisComments.hxx \
src/decoder/vorbis_comments.h \ src/decoder/VorbisDecoderPlugin.cxx src/decoder/VorbisDecoderPlugin.h
src/decoder/vorbis_decoder_plugin.c
endif endif
if HAVE_FLAC if HAVE_FLAC

View File

@ -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 * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,7 +18,7 @@
*/ */
#include "config.h" #include "config.h"
#include "vorbis_comments.h" #include "VorbisComments.hxx"
#include "XiphTags.h" #include "XiphTags.h"
#include "tag.h" #include "tag.h"
#include "tag_table.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) for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
if (vorbis_copy_comment(comment, if (vorbis_copy_comment(comment,
tag_item_names[i], i, tag_item_names[i], tag_type(i),
handler, handler_ctx)) handler, handler_ctx))
return; return;
} }

View File

@ -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 * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * 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. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_VORBIS_COMMENTS_H #ifndef MPD_VORBIS_COMMENTS_HXX
#define MPD_VORBIS_COMMENTS_H #define MPD_VORBIS_COMMENTS_HXX
#include "check.h" #include "check.h"

View File

@ -18,10 +18,16 @@
*/ */
#include "config.h" #include "config.h"
#include "vorbis_comments.h" #include "VorbisDecoderPlugin.h"
#include "VorbisComments.hxx"
#include "decoder_api.h"
extern "C" {
#include "ogg_codec.h" #include "ogg_codec.h"
#include "audio_check.h" #include "audio_check.h"
#include "uri.h" #include "uri.h"
}
#include "tag_handler.h" #include "tag_handler.h"
#ifndef HAVE_TREMOR #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) 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, size_t ret = decoder_read(vis->decoder, vis->input_stream,
ptr, size * nmemb); 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) 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 && return vis->seekable &&
(!vis->decoder || decoder_get_command(vis->decoder) != DECODE_COMMAND_STOP) && (!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) 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; return (long)vis->input_stream->offset;
} }
static const ov_callbacks vorbis_is_callbacks = { static const ov_callbacks vorbis_is_callbacks = {
.read_func = ogg_read_cb, ogg_read_cb,
.seek_func = ogg_seek_cb, ogg_seek_cb,
.close_func = ogg_close_cb, ogg_close_cb,
.tell_func = ogg_tell_cb, ogg_tell_cb,
}; };
static const char * static const char *
@ -343,9 +349,14 @@ static const char *const vorbis_mime_types[] = {
}; };
const struct decoder_plugin vorbis_decoder_plugin = { const struct decoder_plugin vorbis_decoder_plugin = {
.name = "vorbis", "vorbis",
.stream_decode = vorbis_stream_decode, nullptr,
.scan_stream = vorbis_scan_stream, nullptr,
.suffixes = vorbis_suffixes, vorbis_stream_decode,
.mime_types = vorbis_mime_types nullptr,
nullptr,
vorbis_scan_stream,
nullptr,
vorbis_suffixes,
vorbis_mime_types
}; };

View File

@ -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

View File

@ -28,6 +28,7 @@
#include "decoder/dsf_decoder_plugin.h" #include "decoder/dsf_decoder_plugin.h"
#include "decoder/FLACDecoderPlugin.h" #include "decoder/FLACDecoderPlugin.h"
#include "decoder/OpusDecoderPlugin.h" #include "decoder/OpusDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h" #include "decoder/AdPlugDecoderPlugin.h"
#include <glib.h> #include <glib.h>
@ -36,7 +37,6 @@
extern const struct decoder_plugin mad_decoder_plugin; extern const struct decoder_plugin mad_decoder_plugin;
extern const struct decoder_plugin mpg123_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 sndfile_decoder_plugin;
extern const struct decoder_plugin audiofile_decoder_plugin; extern const struct decoder_plugin audiofile_decoder_plugin;
extern const struct decoder_plugin mp4ff_decoder_plugin; extern const struct decoder_plugin mp4ff_decoder_plugin;