Commit 39060b52 authored by Max Kellermann's avatar Max Kellermann

decoder/vorbis: convert to C++

parent 4a36323f
......@@ -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
......
/*
* 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;
}
......
/*
* 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"
......
......@@ -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
};
/*
* 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
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment