summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-02-20 16:12:05 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-02-20 16:12:05 +0000
commita7e25a01baaa3594fa59c0c09a0fbef38428dd81 (patch)
treebed1de279f5c4bff17c4ef41f2bf6fe756d2971a
parent85e40257dc65e3542b785898ddf60482e2d1ab0c (diff)
downloadrockbox-a7e25a01baaa3594fa59c0c09a0fbef38428dd81.tar.gz
rockbox-a7e25a01baaa3594fa59c0c09a0fbef38428dd81.zip
FS#11920: Do not overwrite already existing metadata and take into account string termination. This can save several bytes of the metadata buffer when tags have multiple entries (e.g. multiple gerne tags)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29349 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata/id3tags.c12
-rw-r--r--apps/metadata/metadata_common.c5
-rw-r--r--apps/metadata/mp4.c16
-rw-r--r--apps/plugins/SOURCES2
4 files changed, 24 insertions, 11 deletions
diff --git a/apps/metadata/id3tags.c b/apps/metadata/id3tags.c
index 9ee183a1b3..9143f8ad25 100644
--- a/apps/metadata/id3tags.c
+++ b/apps/metadata/id3tags.c
@@ -358,8 +358,7 @@ static int parseuser( struct mp3entry* entry, char* tag, int bufferpos )
358 358
359 if ((tag - entry->id3v2buf + desc_len + 2) < bufferpos) { 359 if ((tag - entry->id3v2buf + desc_len + 2) < bufferpos) {
360 /* At least part of the value was read, so we can safely try to 360 /* At least part of the value was read, so we can safely try to
361 * parse it 361 * parse it */
362 */
363 value = tag + desc_len + 1; 362 value = tag + desc_len + 1;
364 value_len = bufferpos - (tag - entry->id3v2buf); 363 value_len = bufferpos - (tag - entry->id3v2buf);
365 364
@@ -368,8 +367,7 @@ static int parseuser( struct mp3entry* entry, char* tag, int bufferpos )
368 entry->albumartist = tag; 367 entry->albumartist = tag;
369#if CONFIG_CODEC == SWCODEC 368#if CONFIG_CODEC == SWCODEC
370 } else { 369 } else {
371 value_len = parse_replaygain(tag, value, entry, tag, 370 value_len = parse_replaygain(tag, value, entry, tag, value_len);
372 value_len);
373#endif 371#endif
374 } 372 }
375 } 373 }
@@ -1040,6 +1038,12 @@ void setid3v2title(int fd, struct mp3entry *entry)
1040#endif 1038#endif
1041 if( tr->ppFunc ) 1039 if( tr->ppFunc )
1042 bufferpos = tr->ppFunc(entry, tag, bufferpos); 1040 bufferpos = tr->ppFunc(entry, tag, bufferpos);
1041
1042 /* Trim. Take into account that multiple string contents will
1043 * only be displayed up to their first null termination. All
1044 * content after this null termination is obsolete and can be
1045 * overwritten. */
1046 bufferpos -= (bytesread - strlen(tag));
1043 1047
1044 /* Seek to the next frame */ 1048 /* Seek to the next frame */
1045 if(framelen < totframelen) 1049 if(framelen < totframelen)
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index e1ef9a0d62..4f001775f3 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -337,7 +337,10 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3,
337 p = NULL; 337 p = NULL;
338 } 338 }
339 339
340 if (p) 340 /* Do not overwrite already available metadata. Especially when reading
341 * tags with e.g. multiple genres / artists. This way only the first
342 * of multiple entries is used, all following are dropped. */
343 if (p!=NULL && *p==NULL)
341 { 344 {
342 len = strlen(value); 345 len = strlen(value);
343 len = MIN(len, buf_remaining - 1); 346 len = MIN(len, buf_remaining - 1);
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c
index 706e621234..14aad2203c 100644
--- a/apps/metadata/mp4.c
+++ b/apps/metadata/mp4.c
@@ -117,11 +117,17 @@ static unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer,
117 117
118 if (bytes_read) 118 if (bytes_read)
119 { 119 {
120 (*buffer)[bytes_read] = 0; 120 /* Do not overwrite already available metadata. Especially when reading
121 *dest = *buffer; 121 * tags with e.g. multiple genres / artists. This way only the first
122 length = strlen(*buffer) + 1; 122 * of multiple entries is used, all following are dropped. */
123 *buffer_left -= length; 123 if (*dest == NULL)
124 *buffer += length; 124 {
125 (*buffer)[bytes_read] = 0;
126 *dest = *buffer;
127 length = strlen(*buffer) + 1;
128 *buffer_left -= length;
129 *buffer += length;
130 }
125 } 131 }
126 else 132 else
127 { 133 {
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 7afd97309f..0f804a521b 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -217,7 +217,7 @@ superdom.c
217 217
218 218
219 219
220#ifdef HAVE_TEST_PLUGINS /* enable in advanced build options */ 220#if 1//def HAVE_TEST_PLUGINS /* enable in advanced build options */
221#ifdef HAVE_ADJUSTABLE_CPU_FREQ 221#ifdef HAVE_ADJUSTABLE_CPU_FREQ
222test_boost.c 222test_boost.c
223#endif 223#endif