diff options
| author | Brandon Low <lostlogic@rockbox.org> | 2006-04-17 20:32:25 +0000 |
|---|---|---|
| committer | Brandon Low <lostlogic@rockbox.org> | 2006-04-17 20:32:25 +0000 |
| commit | 5286c7ddb8d9744ef3acad7d59dff26130c981d5 (patch) | |
| tree | 2ed1e68e78aafdada2ad6fcef6deb9c9f67a54a3 | |
| parent | 095ae809eb634d239a98db47c90d92dc302a2283 (diff) | |
| download | rockbox-5286c7ddb8d9744ef3acad7d59dff26130c981d5.zip rockbox-5286c7ddb8d9744ef3acad7d59dff26130c981d5.tar.gz rockbox-5286c7ddb8d9744ef3acad7d59dff26130c981d5.tar.bz2 rockbox-5286c7ddb8d9744ef3acad7d59dff26130c981d5.tar.xz | |
Add copy and adjust helper for mp3entry struct as it is 1) not copy safe and 2) nonobvious that its not copy safe
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9709 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/export/id3.h | 2 | ||||
| -rw-r--r-- | firmware/id3.c | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 3849404..cc0d422 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -138,5 +138,7 @@ bool mp3info(struct mp3entry *entry, const char *filename, bool v1first); char* id3_get_genre(const struct mp3entry* id3); char* id3_get_codec(const struct mp3entry* id3); int getid3v2len(int fd); +void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig); +void copy_mp3entry(struct mp3entry *dest, struct mp3entry *orig); #endif diff --git a/firmware/id3.c b/firmware/id3.c index aa370e8..1188da9 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -1013,6 +1013,40 @@ bool mp3info(struct mp3entry *entry, const char *filename, bool v1first) return false; } +void adjust_mp3entry(struct mp3entry *entry, void *dest, void *orig) +{ + long offset; + if (orig > dest) + offset = - ((size_t)orig - (size_t)dest); + else + offset = (size_t)dest - (size_t)orig; + + if (entry->title) + entry->title += offset; + if (entry->artist) + entry->artist += offset; + if (entry->album) + entry->album += offset; + if (entry->genre_string) + entry->genre_string += offset; + if (entry->track_string) + entry->track_string += offset; + if (entry->year_string) + entry->year_string += offset; + if (entry->composer) + entry->composer += offset; + if (entry->track_gain_string) + entry->track_gain_string += offset; + if (entry->album_gain_string) + entry->album_gain_string += offset; +} + +void copy_mp3entry(struct mp3entry *dest, struct mp3entry *orig) +{ + memcpy(dest, orig, sizeof(struct mp3entry)); + adjust_mp3entry(dest, dest, orig); +} + #ifdef DEBUG_STANDALONE char *secs2str(int ms) |