aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/MadDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-07-30 20:11:57 +0200
committerMax Kellermann <max@duempel.org>2013-07-30 20:19:53 +0200
commit06f898cc1240a29b293de0e97ad95a4fdc971254 (patch)
tree001a6d3db039cdc03323f3bfddc13b94bde31ce4 /src/decoder/MadDecoderPlugin.cxx
parent6a9ab8bc0e2f5d34803513bb2d94d041a607a58c (diff)
downloadmpd-06f898cc1240a29b293de0e97ad95a4fdc971254.tar.gz
mpd-06f898cc1240a29b293de0e97ad95a4fdc971254.tar.xz
mpd-06f898cc1240a29b293de0e97ad95a4fdc971254.zip
tag: convert to C++
Diffstat (limited to '')
-rw-r--r--src/decoder/MadDecoderPlugin.cxx32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx
index c9b2f0a6c..9f36fd86b 100644
--- a/src/decoder/MadDecoderPlugin.cxx
+++ b/src/decoder/MadDecoderPlugin.cxx
@@ -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()) {}