aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mp3_plugin.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-03 03:11:58 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-03 03:14:17 -0700
commit3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e (patch)
tree49dd735d55dd8d5964c4273998a2f3fc454534bb /src/inputPlugins/mp3_plugin.c
parent86d4a80b0069b2be368bfe4af164be5ff72a48b4 (diff)
parentcdc9bb460e9536577d2747d51c76306a91b3d064 (diff)
downloadmpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.tar.gz
mpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.tar.xz
mpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.zip
Merge branch 'mk/tag'
* mk/tag: (22 commits) tag: fix segfault on update utf8.h: Fix build (broken os_compat.h #include) tag: optimize tag_dup(), copy item references tag: fix the shout and oggflac plugins const pointers tag: static directory name tag: try not to reallocate tag.items in every add() call song: don't export newNullSong() tag: try not to duplicate the input string tag: pass length to fix_utf8() added "length" parameter to validUtf8String() assert value!=NULL in fix_utf8() tag: converted macro fixUtf8() to an inline function tag: added a pool for tag items tag: converted tag_item.value to a char array removed tree.c tag: converted MpdTag.items to a pointer list tag: moved code to tag_id3.c wavpack: tag_new() cannot fail tag: converted tag_add_item() to an inline function ...
Diffstat (limited to 'src/inputPlugins/mp3_plugin.c')
-rw-r--r--src/inputPlugins/mp3_plugin.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index f1304f401..ff3de80a3 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -301,13 +301,13 @@ static ReplayGainInfo *parseId3ReplayGainInfo(struct id3_tag *tag)
#ifdef HAVE_ID3TAG
static void mp3_parseId3Tag(mp3DecodeData * data, size_t tagsize,
- MpdTag ** mpdTag, ReplayGainInfo ** replayGainInfo)
+ struct mpd_tag ** mpdTag, ReplayGainInfo ** replayGainInfo)
{
struct id3_tag *id3Tag = NULL;
id3_length_t count;
id3_byte_t const *id3_data;
id3_byte_t *allocated = NULL;
- MpdTag *tmpMpdTag;
+ struct mpd_tag *tmpMpdTag;
ReplayGainInfo *tmpReplayGainInfo;
count = data->stream.bufend - data->stream.this_frame;
@@ -348,10 +348,10 @@ static void mp3_parseId3Tag(mp3DecodeData * data, size_t tagsize,
goto fail;
if (mpdTag) {
- tmpMpdTag = parseId3Tag(id3Tag);
+ tmpMpdTag = tag_id3_import(id3Tag);
if (tmpMpdTag) {
if (*mpdTag)
- freeMpdTag(*mpdTag);
+ tag_free(*mpdTag);
*mpdTag = tmpMpdTag;
}
}
@@ -373,7 +373,7 @@ fail:
#endif
static enum mp3_action
-decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag,
+decodeNextFrameHeader(mp3DecodeData * data, struct mpd_tag ** tag,
ReplayGainInfo ** replayGainInfo)
{
enum mad_layer layer;
@@ -688,7 +688,7 @@ static int parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
}
static int decodeFirstFrame(mp3DecodeData * data,
- MpdTag ** tag, ReplayGainInfo ** replayGainInfo)
+ struct mpd_tag ** tag, ReplayGainInfo ** replayGainInfo)
{
struct xing xing;
struct lame lame;
@@ -811,7 +811,7 @@ static int getMp3TotalTime(char *file)
}
static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
- MpdTag ** tag,
+ struct mpd_tag ** tag,
ReplayGainInfo ** replayGainInfo)
{
initMp3DecodeData(data, inStream);
@@ -819,7 +819,7 @@ static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
if (decodeFirstFrame(data, tag, replayGainInfo) < 0) {
mp3DecodeDataFinalize(data);
if (tag && *tag)
- freeMpdTag(*tag);
+ tag_free(*tag);
return -1;
}
@@ -923,13 +923,12 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
}
if (data->inStream->metaTitle) {
- MpdTag *tag = newMpdTag();
+ struct mpd_tag *tag = tag_new();
if (data->inStream->metaName) {
- addItemToMpdTag(tag,
- TAG_ITEM_NAME,
- data->inStream->metaName);
+ tag_add_item(tag, TAG_ITEM_NAME,
+ data->inStream->metaName);
}
- addItemToMpdTag(tag, TAG_ITEM_TITLE,
+ tag_add_item(tag, TAG_ITEM_TITLE,
data->inStream->metaTitle);
free(data->inStream->metaTitle);
data->inStream->metaTitle = NULL;
@@ -1033,7 +1032,7 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data,
static int mp3_decode(InputStream * inStream)
{
mp3DecodeData data;
- MpdTag *tag = NULL;
+ struct mpd_tag *tag = NULL;
ReplayGainInfo *replayGainInfo = NULL;
if (openMp3FromInputStream(inStream, &data, &tag, &replayGainInfo) < 0) {
@@ -1051,23 +1050,23 @@ static int mp3_decode(InputStream * inStream)
if (inStream->metaTitle) {
if (tag)
- freeMpdTag(tag);
- tag = newMpdTag();
- addItemToMpdTag(tag, TAG_ITEM_TITLE, inStream->metaTitle);
+ tag_free(tag);
+ tag = tag_new();
+ tag_add_item(tag, TAG_ITEM_TITLE, inStream->metaTitle);
free(inStream->metaTitle);
inStream->metaTitle = NULL;
if (inStream->metaName) {
- addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
+ tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
}
} else if (tag) {
if (inStream->metaName) {
- clearItemsFromMpdTag(tag, TAG_ITEM_NAME);
- addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
+ tag_clear_items_by_type(tag, TAG_ITEM_NAME);
+ tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
}
} else if (inStream->metaName) {
- tag = newMpdTag();
+ tag = tag_new();
if (inStream->metaName) {
- addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
+ tag_add_item(tag, TAG_ITEM_NAME, inStream->metaName);
}
}
if (tag)
@@ -1081,18 +1080,18 @@ static int mp3_decode(InputStream * inStream)
return 0;
}
-static MpdTag *mp3_tagDup(char *file)
+static struct mpd_tag *mp3_tagDup(char *file)
{
- MpdTag *ret = NULL;
+ struct mpd_tag *ret = NULL;
int total_time;
- ret = id3Dup(file);
+ ret = tag_id3_load(file);
total_time = getMp3TotalTime(file);
if (total_time >= 0) {
if (!ret)
- ret = newMpdTag();
+ ret = tag_new();
ret->time = total_time;
} else {
DEBUG("mp3_tagDup: Failed to get total song time from: %s\n",