diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-09-11 22:36:42 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-09-12 19:16:02 -0400 |
commit | 79bed1f422a79a18e40443b9ada647aeb1c0cc61 (patch) | |
tree | f9fe9e18e54c379bc67ded5e9569d43e799c580f | |
parent | 2a0f3c8276c397b384ffa8b57fa62f38f3cea6a9 (diff) | |
download | rockbox-79bed1f422.tar.gz rockbox-79bed1f422.zip |
RFC skin_tokens remove a static buffer
it was hard to hit this branch, I had to comment out:
ln 555 else if (offset == 1)
ln 556 pid3 = state->nid3;
as far as I can tell the reason for the separate filename buffer
was due to the failure mode of audio_peek_track() wiping
the id3->path, stands to reason for me that we can just fill it
again
-Already found a gotcha playlist_peek() mutates the buffer
makes me like this solution less, might rework tagcache_fill_tags()
instead
--Fixed
Change-Id: I4a2ee71a8e2d0739c9e141948b71c2ed36296e3b
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 19 | ||||
-rw-r--r-- | apps/tagcache.c | 9 |
2 files changed, 20 insertions, 8 deletions
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 082619432f..4bd1ffea31 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -556,20 +556,29 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename) pid3 = state->nid3; else { - static char filename_buf[MAX_PATH + 1]; - fname = playlist_peek(offset, filename_buf, sizeof(filename_buf)); + static struct mp3entry tempid3; /* Note: path gets passed to outside fns */ + memset(&tempid3, 0, sizeof(struct mp3entry)); + /*static char filename_buf[MAX_PATH + 1];removed g#5926 */ + fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path)); *filename = (char*)fname; - static struct mp3entry tempid3; + if ( #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) - tagcache_fill_tags(&tempid3, fname) || + tagcache_fill_tags(&tempid3, NULL) || #endif audio_peek_track(&tempid3, offset) ) { pid3 = &tempid3; } + else /* failed */ + { + /* ensure *filename gets the path, audio_peek_track() cleared it */ + fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path)); + *filename = (char*)fname; + } } + return pid3; } @@ -710,8 +719,6 @@ const char *get_token_value(struct gui_wps *gwps, return NULL; id3 = get_mp3entry_from_offset(token->next? 1: offset, &filename); - if (id3) - filename = id3->path; #if CONFIG_RTC struct tm* tm = NULL; diff --git a/apps/tagcache.c b/apps/tagcache.c index 1412647368..5bfeb82481 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -2085,13 +2085,18 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename) return false; /* Find the corresponding entry in tagcache. */ + + if (filename != NULL) + memset(id3, 0, sizeof(struct mp3entry)); + else /* Note: caller clears id3 prior to call */ + filename = id3->path; + idx_id = find_entry_ram(filename); if (idx_id < 0) return false; entry = &tcramcache.hdr->indices[idx_id]; - - memset(id3, 0, sizeof(struct mp3entry)); + char* buf = id3->id3v2buf; ssize_t remaining = sizeof(id3->id3v2buf); |