forked from len0rd/rockbox
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
This commit is contained in:
parent
095ae809eb
commit
5286c7ddb8
2 changed files with 36 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue