tag: convert to C++
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "TagId3.hxx"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* for SEEK_SET, SEEK_CUR */
|
||||
|
||||
#ifdef HAVE_ID3TAG
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
|
||||
@@ -43,8 +43,7 @@ flac_data::flac_data(struct decoder *_decoder,
|
||||
|
||||
flac_data::~flac_data()
|
||||
{
|
||||
if (tag != nullptr)
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
}
|
||||
|
||||
static enum sample_format
|
||||
|
||||
@@ -81,7 +81,7 @@ struct flac_data : public FlacInput {
|
||||
struct decoder *decoder;
|
||||
struct input_stream *input_stream;
|
||||
|
||||
struct tag *tag;
|
||||
Tag *tag;
|
||||
|
||||
flac_data(struct decoder *decoder, struct input_stream *input_stream);
|
||||
~flac_data();
|
||||
|
||||
@@ -172,11 +172,11 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
|
||||
data->first_frame = t_start;
|
||||
|
||||
while (true) {
|
||||
if (data->tag != nullptr && !tag_is_empty(data->tag)) {
|
||||
if (data->tag != nullptr && !data->tag->IsEmpty()) {
|
||||
cmd = decoder_tag(data->decoder, data->input_stream,
|
||||
data->tag);
|
||||
tag_free(data->tag);
|
||||
data->tag = tag_new();
|
||||
delete data->tag;
|
||||
data->tag = new Tag();
|
||||
} else
|
||||
cmd = decoder_get_command(decoder);
|
||||
|
||||
@@ -260,7 +260,7 @@ flac_decode_internal(struct decoder * decoder,
|
||||
return;
|
||||
|
||||
struct flac_data data(decoder, input_stream);
|
||||
data.tag = tag_new();
|
||||
data.tag = new Tag();
|
||||
|
||||
FLAC__StreamDecoderInitStatus status =
|
||||
stream_init(flac_dec, &data, is_ogg);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "FlacMetadata.hxx"
|
||||
#include "XiphTags.hxx"
|
||||
#include "tag.h"
|
||||
#include "Tag.hxx"
|
||||
#include "TagHandler.hxx"
|
||||
#include "TagTable.hxx"
|
||||
#include "replay_gain_info.h"
|
||||
@@ -228,7 +228,7 @@ flac_scan_metadata(const FLAC__StreamMetadata *block,
|
||||
}
|
||||
|
||||
void
|
||||
flac_vorbis_comments_to_tag(struct tag *tag,
|
||||
flac_vorbis_comments_to_tag(Tag *tag,
|
||||
const FLAC__StreamMetadata_VorbisComment *comment)
|
||||
{
|
||||
flac_scan_comments(comment, &add_tag_handler, tag);
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
};
|
||||
|
||||
struct tag_handler;
|
||||
struct tag;
|
||||
struct Tag;
|
||||
struct replay_gain_info;
|
||||
|
||||
static inline unsigned
|
||||
@@ -130,7 +130,7 @@ flac_parse_mixramp(char **mixramp_start, char **mixramp_end,
|
||||
const FLAC__StreamMetadata *block);
|
||||
|
||||
void
|
||||
flac_vorbis_comments_to_tag(struct tag *tag,
|
||||
flac_vorbis_comments_to_tag(Tag *tag,
|
||||
const FLAC__StreamMetadata_VorbisComment *comment);
|
||||
|
||||
void
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <mad.h>
|
||||
|
||||
@@ -143,8 +144,8 @@ struct MadDecoder {
|
||||
|
||||
bool Seek(long offset);
|
||||
bool FillBuffer();
|
||||
void ParseId3(size_t tagsize, struct tag **mpd_tag);
|
||||
enum mp3_action DecodeNextFrameHeader(struct tag **tag);
|
||||
void ParseId3(size_t tagsize, Tag **mpd_tag);
|
||||
enum mp3_action DecodeNextFrameHeader(Tag **tag);
|
||||
enum mp3_action DecodeNextFrame();
|
||||
|
||||
gcc_pure
|
||||
@@ -158,7 +159,7 @@ struct MadDecoder {
|
||||
*/
|
||||
void FileSizeToSongLength();
|
||||
|
||||
bool DecodeFirstFrame(struct tag **tag);
|
||||
bool DecodeFirstFrame(Tag **tag);
|
||||
|
||||
gcc_pure
|
||||
long TimeToFrame(double t) const;
|
||||
@@ -334,7 +335,7 @@ parse_id3_mixramp(char **mixramp_start, char **mixramp_end,
|
||||
#endif
|
||||
|
||||
inline void
|
||||
MadDecoder::ParseId3(size_t tagsize, struct tag **mpd_tag)
|
||||
MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
|
||||
{
|
||||
#ifdef HAVE_ID3TAG
|
||||
struct id3_tag *id3_tag = nullptr;
|
||||
@@ -379,10 +380,9 @@ MadDecoder::ParseId3(size_t tagsize, struct tag **mpd_tag)
|
||||
}
|
||||
|
||||
if (mpd_tag) {
|
||||
struct tag *tmp_tag = tag_id3_import(id3_tag);
|
||||
Tag *tmp_tag = tag_id3_import(id3_tag);
|
||||
if (tmp_tag != nullptr) {
|
||||
if (*mpd_tag != nullptr)
|
||||
tag_free(*mpd_tag);
|
||||
delete *mpd_tag;
|
||||
*mpd_tag = tmp_tag;
|
||||
}
|
||||
}
|
||||
@@ -453,7 +453,7 @@ id3_tag_query(const void *p0, size_t length)
|
||||
#endif /* !HAVE_ID3TAG */
|
||||
|
||||
enum mp3_action
|
||||
MadDecoder::DecodeNextFrameHeader(struct tag **tag)
|
||||
MadDecoder::DecodeNextFrameHeader(Tag **tag)
|
||||
{
|
||||
if ((stream.buffer == nullptr || stream.error == MAD_ERROR_BUFLEN) &&
|
||||
!FillBuffer())
|
||||
@@ -807,7 +807,7 @@ MadDecoder::FileSizeToSongLength()
|
||||
}
|
||||
|
||||
inline bool
|
||||
MadDecoder::DecodeFirstFrame(struct tag **tag)
|
||||
MadDecoder::DecodeFirstFrame(Tag **tag)
|
||||
{
|
||||
struct xing xing;
|
||||
struct lame lame;
|
||||
@@ -1079,13 +1079,13 @@ MadDecoder::Read()
|
||||
bool skip = false;
|
||||
|
||||
do {
|
||||
struct tag *tag = nullptr;
|
||||
Tag *tag = nullptr;
|
||||
|
||||
ret = DecodeNextFrameHeader(&tag);
|
||||
|
||||
if (tag != nullptr) {
|
||||
decoder_tag(decoder, input_stream, tag);
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
}
|
||||
} while (ret == DECODE_CONT);
|
||||
if (ret == DECODE_BREAK)
|
||||
@@ -1113,10 +1113,9 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||
{
|
||||
MadDecoder data(decoder, input_stream);
|
||||
|
||||
struct tag *tag = nullptr;
|
||||
Tag *tag = nullptr;
|
||||
if (!data.DecodeFirstFrame(&tag)) {
|
||||
if (tag != nullptr)
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
|
||||
if (decoder_get_command(decoder) == DECODE_COMMAND_NONE)
|
||||
g_warning
|
||||
@@ -1134,8 +1133,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
|
||||
if (tag != nullptr)
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1145,7 +1143,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
||||
|
||||
if (tag != nullptr) {
|
||||
decoder_tag(decoder, input_stream, tag);
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
}
|
||||
|
||||
while (data.Read()) {}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "config.h"
|
||||
#include "OggCodec.hxx"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
enum ogg_codec
|
||||
ogg_codec_detect(struct decoder *decoder, struct input_stream *is)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
#define G_LOG_DOMAIN "opus"
|
||||
@@ -221,16 +222,16 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
inline enum decoder_command
|
||||
MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
||||
{
|
||||
struct tag *tag = tag_new();
|
||||
Tag tag;
|
||||
|
||||
enum decoder_command cmd;
|
||||
if (ScanOpusTags(packet.packet, packet.bytes, &add_tag_handler, tag) &&
|
||||
!tag_is_empty(tag))
|
||||
cmd = decoder_tag(decoder, input_stream, tag);
|
||||
if (ScanOpusTags(packet.packet, packet.bytes,
|
||||
&add_tag_handler, &tag) &&
|
||||
!tag.IsEmpty())
|
||||
cmd = decoder_tag(decoder, input_stream, &tag);
|
||||
else
|
||||
cmd = decoder_get_command(decoder);
|
||||
|
||||
tag_free(tag);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ extern "C" {
|
||||
|
||||
#include <glib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* for SEEK_SET */
|
||||
|
||||
#undef G_LOG_DOMAIN
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "VorbisComments.hxx"
|
||||
#include "XiphTags.hxx"
|
||||
#include "tag.h"
|
||||
#include "Tag.hxx"
|
||||
#include "TagTable.hxx"
|
||||
#include "TagHandler.hxx"
|
||||
#include "replay_gain_info.h"
|
||||
@@ -135,14 +135,14 @@ vorbis_comments_scan(char **comments,
|
||||
|
||||
}
|
||||
|
||||
struct tag *
|
||||
Tag *
|
||||
vorbis_comments_to_tag(char **comments)
|
||||
{
|
||||
struct tag *tag = tag_new();
|
||||
Tag *tag = new Tag();
|
||||
vorbis_comments_scan(comments, &add_tag_handler, tag);
|
||||
|
||||
if (tag_is_empty(tag)) {
|
||||
tag_free(tag);
|
||||
if (tag->IsEmpty()) {
|
||||
delete tag;
|
||||
tag = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
struct replay_gain_info;
|
||||
struct tag_handler;
|
||||
struct Tag;
|
||||
|
||||
bool
|
||||
vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments);
|
||||
@@ -32,7 +33,7 @@ void
|
||||
vorbis_comments_scan(char **comments,
|
||||
const struct tag_handler *handler, void *handler_ctx);
|
||||
|
||||
struct tag *
|
||||
Tag *
|
||||
vorbis_comments_to_tag(char **comments);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -154,12 +154,12 @@ static void
|
||||
vorbis_send_comments(struct decoder *decoder, struct input_stream *is,
|
||||
char **comments)
|
||||
{
|
||||
struct tag *tag = vorbis_comments_to_tag(comments);
|
||||
Tag *tag = vorbis_comments_to_tag(comments);
|
||||
if (!tag)
|
||||
return;
|
||||
|
||||
decoder_tag(decoder, is, tag);
|
||||
tag_free(tag);
|
||||
delete tag;
|
||||
}
|
||||
|
||||
#ifndef HAVE_TREMOR
|
||||
|
||||
@@ -26,6 +26,7 @@ extern "C" {
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <sidplay/sidplay2.h>
|
||||
|
||||
Reference in New Issue
Block a user