diff options
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/_flac_common.c | 12 | ||||
-rw-r--r-- | src/inputPlugins/_flac_common.h | 6 | ||||
-rw-r--r-- | src/inputPlugins/aac_plugin.c | 8 | ||||
-rw-r--r-- | src/inputPlugins/audiofile_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 20 | ||||
-rw-r--r-- | src/inputPlugins/mod_plugin.c | 8 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 51 | ||||
-rw-r--r-- | src/inputPlugins/mp4_plugin.c | 30 | ||||
-rw-r--r-- | src/inputPlugins/mpc_plugin.c | 10 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/oggvorbis_plugin.c | 24 | ||||
-rw-r--r-- | src/inputPlugins/wavpack_plugin.c | 13 |
12 files changed, 95 insertions, 99 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index 6890c7c50..9950f75db 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -101,7 +101,7 @@ static const char *VORBIS_COMMENT_DISC_KEY = "discnumber"; static unsigned int commentMatchesAddToTag(const FLAC__StreamMetadata_VorbisComment_Entry * entry, unsigned int itemType, - MpdTag ** tag) + struct mpd_tag ** tag) { const char *str; size_t slen; @@ -123,10 +123,10 @@ static unsigned int commentMatchesAddToTag(const if ((vlen > 0) && (0 == strncasecmp(str, (char *)entry->entry, slen)) && (*(entry->entry + slen) == '=')) { if (!*tag) - *tag = newMpdTag(); + *tag = tag_new(); - addItemToMpdTagWithLen(*tag, itemType, - (char *)(entry->entry + slen + 1), vlen); + tag_add_item_n(*tag, itemType, + (char *)(entry->entry + slen + 1), vlen); return 1; } @@ -134,8 +134,8 @@ static unsigned int commentMatchesAddToTag(const return 0; } -MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, - MpdTag * tag) +struct mpd_tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, + struct mpd_tag * tag) { unsigned int i, j; FLAC__StreamMetadata_VorbisComment_Entry *comments; diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h index 6fe5bd744..a1b0cac8f 100644 --- a/src/inputPlugins/_flac_common.h +++ b/src/inputPlugins/_flac_common.h @@ -146,7 +146,7 @@ typedef struct { FLAC__uint64 position; InputStream *inStream; ReplayGainInfo *replayGainInfo; - MpdTag *tag; + struct mpd_tag *tag; } FlacData; /* initializes a given FlacData struct */ @@ -157,8 +157,8 @@ void flac_error_common_cb(const char *plugin, FLAC__StreamDecoderErrorStatus status, FlacData * data); -MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, - MpdTag * tag); +struct mpd_tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, + struct mpd_tag *tag); /* keep this inlined, this is just macro but prettier :) */ static inline enum dc_action flacSendChunk(FlacData * data) diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index 512e73e53..dc97c1e08 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -553,14 +553,14 @@ out: return 0; } -static MpdTag *aacTagDup(char *file) +static struct mpd_tag *aacTagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; int file_time = getAacTotalTime(file); if (file_time >= 0) { - if ((ret = id3Dup(file)) == NULL) - ret = newMpdTag(); + if ((ret = tag_id3_load(file)) == NULL) + ret = tag_new(); ret->time = file_time; } else { DEBUG("aacTagDup: Failed to get total song time from: %s\n", diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c index fcebf562b..6fcc98239 100644 --- a/src/inputPlugins/audiofile_plugin.c +++ b/src/inputPlugins/audiofile_plugin.c @@ -116,14 +116,14 @@ static int audiofile_decode(char *path) return 0; } -static MpdTag *audiofileTagDup(char *file) +static struct mpd_tag *audiofileTagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; int total_time = getAudiofileTotalTime(file); if (total_time >= 0) { if (!ret) - ret = newMpdTag(); + ret = tag_new(); ret->time = total_time; } else { DEBUG diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index de0648c90..89e988a03 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -292,9 +292,9 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } -static MpdTag *flacMetadataDup(char *file, int *vorbisCommentFound) +static struct mpd_tag *flacMetadataDup(char *file, int *vorbisCommentFound) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; FLAC__Metadata_SimpleIterator *it; FLAC__StreamMetadata *block = NULL; @@ -338,7 +338,7 @@ static MpdTag *flacMetadataDup(char *file, int *vorbisCommentFound) *vorbisCommentFound = 1; } else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) { if (!ret) - ret = newMpdTag(); + ret = tag_new(); ret->time = ((float)block->data.stream_info. total_samples) / block->data.stream_info.sample_rate + 0.5; @@ -350,9 +350,9 @@ static MpdTag *flacMetadataDup(char *file, int *vorbisCommentFound) return ret; } -static MpdTag *flacTagDup(char *file) +static struct mpd_tag *flacTagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; int foundVorbisComment = 0; ret = flacMetadataDup(file, &foundVorbisComment); @@ -362,10 +362,10 @@ static MpdTag *flacTagDup(char *file) return NULL; } if (!foundVorbisComment) { - MpdTag *temp = id3Dup(file); + struct mpd_tag *temp = tag_id3_load(file); if (temp) { temp->time = ret->time; - freeMpdTag(ret); + tag_free(ret); ret = temp; } } @@ -466,9 +466,9 @@ static int flac_decode(InputStream * inStream) /* some of this stuff is duplicated from oggflac_plugin.c */ extern InputPlugin oggflacPlugin; -static MpdTag *oggflac_tag_dup(char *file) +static struct mpd_tag *oggflac_tag_dup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; FLAC__Metadata_Iterator *it; FLAC__StreamMetadata *block; FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new(); @@ -484,7 +484,7 @@ static MpdTag *oggflac_tag_dup(char *file) ret = copyVorbisCommentBlockToMpdTag(block, ret); } else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) { if (!ret) - ret = newMpdTag(); + ret = tag_new(); ret->time = ((float)block->data.stream_info. total_samples) / block->data.stream_info.sample_rate + 0.5; diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c index df938f0ed..586d87ae9 100644 --- a/src/inputPlugins/mod_plugin.c +++ b/src/inputPlugins/mod_plugin.c @@ -205,9 +205,9 @@ static int mod_decode(char *path) return 0; } -static MpdTag *modTagDup(char *file) +static struct mpd_tag *modTagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; MODULE *moduleHandle; char *title; @@ -224,12 +224,12 @@ static MpdTag *modTagDup(char *file) } Player_Free(moduleHandle); - ret = newMpdTag(); + ret = tag_new(); ret->time = 0; title = xstrdup(Player_LoadTitle(file)); if (title) - addItemToMpdTag(ret, TAG_ITEM_TITLE, title); + tag_add_item(ret, TAG_ITEM_TITLE, title); MikMod_Exit(); 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", diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c index 8e3d02354..cc2b89efc 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -284,9 +284,9 @@ static int mp4_decode(InputStream * inStream) return 0; } -static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound) +static struct mpd_tag *mp4DataDup(char *file, int *mp4MetadataFound) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; InputStream inStream; mp4ff_t *mp4fh; mp4ff_callback_t *callback; @@ -322,14 +322,14 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound) return NULL; } - ret = newMpdTag(); + ret = tag_new(); file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track); if (scale < 0) { mp4ff_close(mp4fh); closeInputStream(&inStream); free(callback); - freeMpdTag(ret); + tag_free(ret); return NULL; } ret->time = ((float)file_time) / scale + 0.5; @@ -341,25 +341,25 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound) mp4ff_meta_get_by_index(mp4fh, i, &item, &value); if (0 == strcasecmp("artist", item)) { - addItemToMpdTag(ret, TAG_ITEM_ARTIST, value); + tag_add_item(ret, TAG_ITEM_ARTIST, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("title", item)) { - addItemToMpdTag(ret, TAG_ITEM_TITLE, value); + tag_add_item(ret, TAG_ITEM_TITLE, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("album", item)) { - addItemToMpdTag(ret, TAG_ITEM_ALBUM, value); + tag_add_item(ret, TAG_ITEM_ALBUM, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("track", item)) { - addItemToMpdTag(ret, TAG_ITEM_TRACK, value); + tag_add_item(ret, TAG_ITEM_TRACK, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("disc", item)) { /* Is that the correct id? */ - addItemToMpdTag(ret, TAG_ITEM_DISC, value); + tag_add_item(ret, TAG_ITEM_DISC, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("genre", item)) { - addItemToMpdTag(ret, TAG_ITEM_GENRE, value); + tag_add_item(ret, TAG_ITEM_GENRE, value); *mp4MetadataFound = 1; } else if (0 == strcasecmp("date", item)) { - addItemToMpdTag(ret, TAG_ITEM_DATE, value); + tag_add_item(ret, TAG_ITEM_DATE, value); *mp4MetadataFound = 1; } @@ -373,19 +373,19 @@ static MpdTag *mp4DataDup(char *file, int *mp4MetadataFound) return ret; } -static MpdTag *mp4TagDup(char *file) +static struct mpd_tag *mp4TagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; int mp4MetadataFound = 0; ret = mp4DataDup(file, &mp4MetadataFound); if (!ret) return NULL; if (!mp4MetadataFound) { - MpdTag *temp = id3Dup(file); + struct mpd_tag *temp = tag_id3_load(file); if (temp) { temp->time = ret->time; - freeMpdTag(ret); + tag_free(ret); ret = temp; } } diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index ea27d1dbf..e5502a2f0 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -273,9 +273,9 @@ static float mpcGetTime(char *file) return total_time; } -static MpdTag *mpcTagDup(char *file) +static struct mpd_tag *mpcTagDup(char *file) { - MpdTag *ret = NULL; + struct mpd_tag *ret = NULL; float total_time = mpcGetTime(file); if (total_time < 0) { @@ -284,11 +284,11 @@ static MpdTag *mpcTagDup(char *file) return NULL; } - ret = apeDup(file); + ret = tag_ape_load(file); if (!ret) - ret = id3Dup(file); + ret = tag_id3_load(file); if (!ret) - ret = newMpdTag(); + ret = tag_new(); ret->time = total_time; return ret; diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index 4b3bb0a6b..841030481 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -28,6 +28,8 @@ #include "../utils.h" #include "../log.h" +#include <OggFLAC/seekable_stream_decoder.h> + static void oggflac_cleanup(FlacData * data, OggFLAC__SeekableStreamDecoder * decoder) { @@ -216,7 +218,7 @@ static void of_metadata_dup_cb(mpd_unused const OggFLAC__SeekableStreamDecoder * switch (block->type) { case FLAC__METADATA_TYPE_STREAMINFO: if (!data->tag) - data->tag = newMpdTag(); + data->tag = tag_new(); data->tag->time = ((float)block->data.stream_info. total_samples) / block->data.stream_info.sample_rate + 0.5; @@ -300,7 +302,7 @@ fail: } /* public functions: */ -static MpdTag *oggflac_TagDup(char *file) +static struct mpd_tag *oggflac_TagDup(char *file) { InputStream inStream; OggFLAC__SeekableStreamDecoder *decoder; diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index d14ae2bac..bb8af4465 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -145,7 +145,7 @@ static const char *VORBIS_COMMENT_DISC_KEY = "discnumber"; static unsigned int ogg_parseCommentAddToTag(char *comment, unsigned int itemType, - MpdTag ** tag) + struct mpd_tag ** tag) { const char *needle; unsigned int len; @@ -163,9 +163,9 @@ static unsigned int ogg_parseCommentAddToTag(char *comment, if (strncasecmp(comment, needle, len) == 0 && *(comment + len) == '=') { if (!*tag) - *tag = newMpdTag(); + *tag = tag_new(); - addItemToMpdTag(*tag, itemType, comment + len + 1); + tag_add_item(*tag, itemType, comment + len + 1); return 1; } @@ -173,9 +173,9 @@ static unsigned int ogg_parseCommentAddToTag(char *comment, return 0; } -static MpdTag *oggCommentsParse(char **comments) +static struct mpd_tag *oggCommentsParse(char **comments) { - MpdTag *tag = NULL; + struct mpd_tag *tag = NULL; while (*comments) { int j; @@ -193,18 +193,18 @@ static void putOggCommentsIntoOutputBuffer(char *streamName, char **comments, float cur_time) { - MpdTag *tag; + struct mpd_tag *tag; tag = oggCommentsParse(comments); if (!tag && streamName) { - tag = newMpdTag(); + tag = tag_new(); } if (!tag) return; if (streamName) { - clearItemsFromMpdTag(tag, TAG_ITEM_NAME); - addItemToMpdTag(tag, TAG_ITEM_NAME, streamName); + tag_clear_items_by_type(tag, TAG_ITEM_NAME); + tag_add_item(tag, TAG_ITEM_NAME, streamName); } metadata_pipe_send(tag, cur_time); @@ -332,9 +332,9 @@ static int oggvorbis_decode(InputStream * inStream) return 0; } -static MpdTag *oggvorbis_TagDup(char *file) +static struct mpd_tag *oggvorbis_TagDup(char *file) { - MpdTag *ret; + struct mpd_tag *ret; FILE *fp; OggVorbis_File vf; @@ -352,7 +352,7 @@ static MpdTag *oggvorbis_TagDup(char *file) ret = oggCommentsParse(ov_comment(&vf, -1)->user_comments); if (!ret) - ret = newMpdTag(); + ret = tag_new(); ret->time = (int)(ov_time_total(&vf, -1) + 0.5); ov_clear(&vf); diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c index c7e024a41..77339dabd 100644 --- a/src/inputPlugins/wavpack_plugin.c +++ b/src/inputPlugins/wavpack_plugin.c @@ -270,10 +270,10 @@ static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc) /* * Reads metainfo from the specified file. */ -static MpdTag *wavpack_tagdup(char *fname) +static struct mpd_tag *wavpack_tagdup(char *fname) { WavpackContext *wpc; - MpdTag *tag; + struct mpd_tag *tag; char error[ERRORLEN]; char *s; int ssize; @@ -285,12 +285,7 @@ static MpdTag *wavpack_tagdup(char *fname) return NULL; } - tag = newMpdTag(); - if (tag == NULL) { - ERROR("failed to newMpdTag()\n"); - return NULL; - } - + tag = tag_new(); tag->time = (float)WavpackGetNumSamples(wpc) / WavpackGetSampleRate(wpc); @@ -314,7 +309,7 @@ static MpdTag *wavpack_tagdup(char *fname) } WavpackGetTagItem(wpc, tagtypes[i].name, s, j); - addItemToMpdTag(tag, tagtypes[i].type, s); + tag_add_item(tag, tagtypes[i].type, s); } } |