1
0
Fork 0
forked from len0rd/rockbox

get_mp3entry_from_offset remove static from struct mp3entry

I think with the recent refactoring we should be able to put mp3entry
on the stack

it should be moved up a level anyway

Change-Id: Idd2af598c48545e3dbc774279b5d2b264012805e
This commit is contained in:
William Wilgus 2024-12-25 00:56:49 -05:00
parent 8981311800
commit 6bec4597bf

View file

@ -542,7 +542,7 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
} }
#endif #endif
static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename) static struct mp3entry* get_mp3entry_from_offset(int offset, struct mp3entry *bufid3, char **filename)
{ {
struct mp3entry* pid3 = NULL; struct mp3entry* pid3 = NULL;
struct wps_state *state = get_wps_state(); struct wps_state *state = get_wps_state();
@ -556,25 +556,24 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
pid3 = state->nid3; pid3 = state->nid3;
else else
{ {
static struct mp3entry tempid3; /* Note: path gets passed to outside fns */ memset(bufid3, 0, sizeof(*bufid3));
memset(&tempid3, 0, sizeof(struct mp3entry));
/*static char filename_buf[MAX_PATH + 1];removed g#5926 */ /*static char filename_buf[MAX_PATH + 1];removed g#5926 */
fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path)); fname = playlist_peek(offset, bufid3->path, sizeof(bufid3->path));
*filename = (char*)fname; *filename = (char*)fname;
if ( if (
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
tagcache_fill_tags(&tempid3, NULL) || tagcache_fill_tags(bufid3, NULL) ||
#endif #endif
audio_peek_track(&tempid3, offset) audio_peek_track(bufid3, offset)
) )
{ {
pid3 = &tempid3; pid3 = bufid3;
} }
else /* failed */ else /* failed */
{ {
/* ensure *filename gets the path, audio_peek_track() cleared it */ /* ensure *filename gets the path, audio_peek_track() cleared it */
fname = playlist_peek(offset, tempid3.path, sizeof(tempid3.path)); fname = playlist_peek(offset, bufid3->path, sizeof(bufid3->path));
*filename = (char*)fname; *filename = (char*)fname;
} }
} }
@ -582,8 +581,9 @@ static struct mp3entry* get_mp3entry_from_offset(int offset, char **filename)
return pid3; return pid3;
} }
/* Tokens which use current id3 go here */ /* Don't inline this; it was broken out of get_token_value to reduce stack usage.
static const char * try_id3_token(struct wps_token *token, int offset, * Tokens which use current id3 go here */
static const char * NOINLINE try_id3_token(struct wps_token *token, int offset,
char *buf, int buf_size, char *buf, int buf_size,
int limit, int *intval) int limit, int *intval)
{ {
@ -591,8 +591,8 @@ static const char * try_id3_token(struct wps_token *token, int offset,
char *filename = NULL; char *filename = NULL;
int numeric_ret = -1; int numeric_ret = -1;
const char *numeric_buf = buf; const char *numeric_buf = buf;
struct mp3entry *id3; struct mp3entry tempid3, *id3;/* Note: struct mp3entry is huge */
id3 = get_mp3entry_from_offset(token->next? 1: offset, &filename); id3 = get_mp3entry_from_offset(token->next? 1: offset, &tempid3, &filename);
if (token->type == SKIN_TOKEN_REPLAYGAIN) if (token->type == SKIN_TOKEN_REPLAYGAIN)
{ {