diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 38494044fa..cc0d422e7a 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 aa370e836e..1188da9fd6 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)