aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2006-08-15 00:47:19 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2006-08-15 00:47:19 +0000
commit8f86c41d97241707638b71ab5fdaff0fdadcdbcb (patch)
tree1e72a679c5d23a0067141cac00f9dec2bfda0a31
parentc2e1ccd968fc665742f436408089482b350853e8 (diff)
downloadmpd-8f86c41d97241707638b71ab5fdaff0fdadcdbcb.tar.gz
mpd-8f86c41d97241707638b71ab5fdaff0fdadcdbcb.tar.xz
mpd-8f86c41d97241707638b71ab5fdaff0fdadcdbcb.zip
Avoid an unnecessary encoding conversion when converting id3v1 tags. Also make getID3Info static.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4642 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/tag.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/tag.c b/src/tag.c
index c3bb807e7..cc7c11e46 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -133,7 +133,7 @@ void printMpdTag(int fd, MpdTag * tag)
}
#ifdef HAVE_ID3TAG
-MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
+static MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
{
struct id3_frame const *frame;
id3_ucs4_t const *ucs4;
@@ -159,29 +159,24 @@ MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag)
if (type == TAG_ITEM_GENRE)
ucs4 = id3_genre_name(ucs4);
- utf8 = id3_ucs4_utf8duplicate(ucs4);
- if (!utf8)
- continue;
-
- if (isId3v1(tag)) {
- encoding = getConfigParamValue(CONF_ID3V1_ENCODING);
- if (encoding) {
- setCharSetConversion("ISO-8859-1", "UTF-8");
- isostr = convStrDup((char *)utf8);
- free(utf8);
- if (mpd_unlikely(!isostr))
- continue;
- setCharSetConversion("UTF-8", encoding);
- utf8 = (id3_utf8_t *)convStrDup(isostr);
- if (!utf8) {
- DEBUG("Unable to convert %s string to "
- "UTF-8: '%s'\n",
- encoding, isostr);
- free(isostr);
- continue;
- }
+ if (isId3v1(tag) &&
+ (encoding = getConfigParamValue(CONF_ID3V1_ENCODING))) {
+ isostr = id3_ucs4_latin1duplicate(ucs4);
+ if (mpd_unlikely(!isostr))
+ continue;
+ setCharSetConversion("UTF-8", encoding);
+ utf8 = (id3_utf8_t *)convStrDup(isostr);
+ if (!utf8) {
+ DEBUG("Unable to convert %s string to UTF-8: "
+ "'%s'\n", encoding, isostr);
free(isostr);
+ continue;
}
+ free(isostr);
+ } else {
+ utf8 = id3_ucs4_utf8duplicate(ucs4);
+ if (mpd_unlikely(!utf8))
+ continue;
}
if (mpdTag == NULL)