audio_peek_track should copy the struct mp3entry instead of pointing directly into the buffer. Despite the dire warning, caller does in fact yield/sleep and its usage is too nonlocalized to control that reliably.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29275 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-02-10 10:26:07 +00:00
parent 6f9d2ad130
commit edfff8a5ef
3 changed files with 16 additions and 13 deletions

View file

@ -563,18 +563,16 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
fname = playlist_peek(offset, filename_buf, sizeof(filename_buf));
*filename = (char*)fname;
#if CONFIG_CODEC == SWCODEC
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
static struct mp3entry tempid3;
if (tagcache_fill_tags(&tempid3, fname))
if (
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
tagcache_fill_tags(&tempid3, fname) ||
#endif
audio_peek_track(&tempid3, offset)
)
{
pid3 = &tempid3;
}
else
#endif
{
if (!audio_peek_track(&pid3, offset))
pid3 = NULL;
}
#endif
}
return pid3;

View file

@ -628,8 +628,8 @@ struct mp3entry* audio_next_track(void)
return NULL;
}
/* gets a pointer to the id3 data, Not thread safe!, DON'T yield()/sleep() */
bool audio_peek_track(struct mp3entry** id3, int offset)
/* gets a copy of the id3 data */
bool audio_peek_track(struct mp3entry* id3, int offset)
{
int next_idx;
int new_offset = ci.new_track + wps_offset + offset;
@ -640,8 +640,13 @@ bool audio_peek_track(struct mp3entry** id3, int offset)
if (tracks[next_idx].id3_hid >= 0)
{
return bufgetdata(tracks[next_idx].id3_hid, 0, (void**)id3)
== sizeof(struct mp3entry);
struct mp3entry *id3src;
if (bufgetdata(tracks[next_idx].id3_hid, 0, (void**)&id3src)
== sizeof(struct mp3entry))
{
copy_mp3entry(id3, id3src);
return true;
}
}
return false;
}

View file

@ -60,7 +60,7 @@ void audio_ff_rewind(long newpos);
void audio_flush_and_reload_tracks(void);
struct mp3entry* audio_current_track(void);
struct mp3entry* audio_next_track(void);
bool audio_peek_track(struct mp3entry** id3, int offset);
bool audio_peek_track(struct mp3entry* id3, int offset);
#ifdef HAVE_DISK_STORAGE
void audio_set_buffer_margin(int setting);
#endif