metadata add audio_fmt to get_metadata_ex
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Sat, 27 Jun 2026 14:26:34 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 3cd286d8f8fa1d2c5110c955562b1ca177d812f5 Author: William Wilgus <[email protected]> Date: Sat Jun 27 14:14:01 2026 -0400 metadata add audio_fmt to get_metadata_ex tagcache.c add_tagcache() and potentially skin_tokens.c wps_playlist_percent_prepare() make calls to probe_file_format() prior to calling get_metadata_ex resulting in some small amout of duplicated work especially in the case of add_tagcache this can add up to a lot of duplicated work breaks out audio_fmt so these can supply the afmt other callers just supply probe_file_format(trackname) in the function call Change-Id: I8084213b8ee7e04d76dce0986beb83d443ac804b diff --git a/apps/buffering.c b/apps/buffering.c index a4c179af41..4430f63678 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -651,8 +651,8 @@ static bool buffer_handle(int handle_id, size_t to_buffer) trigger_cpu_boost(); if (h->type == TYPE_ID3) { - get_metadata_ex(ringbuf_ptr(h->data), - h->fd, h->path, METADATA_CLOSE_FD_ON_EXIT); + get_metadata_ex(ringbuf_ptr(h->data), h->fd, h->path, + probe_file_format(h->path), METADATA_CLOSE_FD_ON_EXIT); h->fd = -1; /* with above, behavior same as close_fd */ h->widx = ringbuf_add(h->data, h->filesize); h->end = h->filesize; diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 43b727a321..cdafea2b5b 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -297,7 +297,7 @@ void wps_playlist_percent_prepare(void) if (afmt != last_afmt || last_bps == 0 || amount <= 50 || (amount <= 250 && ata_disk_isssd())) // TODO tune this for harddisk devices { - if (get_metadata_ex(tmp, fd, info.filename, + if (get_metadata_ex(tmp, fd, info.filename, afmt, METADATA_EXCLUDE_ID3_PATH | METADATA_EXCLUDE_NORMALIZE)) { secs = tmp->length / 1000; @@ -314,8 +314,8 @@ void wps_playlist_percent_prepare(void) close(fd); } #else - if (get_metadata_ex(tmp, -1, info.filename, - METADATA_EXCLUDE_ID3_PATH | METADATA_EXCLUDE_NORMALIZE)) + if (get_metadata_ex(tmp, -1, info.filename, probe_file_format(info.filename), + METADATA_EXCLUDE_ID3_PATH | METADATA_EXCLUDE_NORMALIZE)) { secs = tmp->length / 1000; mins = MIN(MAX(1, (secs + 30) / 60), 65535ul);/* minutes, rounded to nearest */ diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 2c0ac22541..0548ddcd5c 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -307,7 +307,8 @@ static bool retrieve_id3_tags(const int index, const char* name, struct mp3entry if (!id3_retrieval_successful) { /* Read from disk: retrieves frequency, file size, and codec */ - id3_retrieval_successful = get_metadata_ex(id3, -1, name, flags); + id3_retrieval_successful = get_metadata_ex(id3, -1, name, + probe_file_format(name), flags); } return id3_retrieval_successful; } diff --git a/apps/tagcache.c b/apps/tagcache.c index 69e44fb39a..95bcfbd968 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -2291,8 +2291,9 @@ static void NO_INLINE add_tagcache(char *path, unsigned long mtime) } /* Check if the file is supported. */ - if (probe_file_format(path) == AFMT_UNKNOWN) - return ; + int afmt = probe_file_format(path); + if (afmt == AFMT_UNKNOWN) + return; /* Check if the file is already cached. */ #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) @@ -2338,7 +2339,7 @@ static void NO_INLINE add_tagcache(char *path, unsigned long mtime) /*memset(&id3, 0, sizeof(struct mp3entry)); -- get_metadata does this for us */ memset(&entry, 0, sizeof(struct temp_file_entry)); memset(&tracknumfix, 0, sizeof(tracknumfix)); - ret = get_metadata_ex(&id3, -1, path, METADATA_EXCLUDE_ID3_PATH); + ret = get_metadata_ex(&id3, -1, path, afmt, METADATA_EXCLUDE_ID3_PATH); if (!ret) { diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c index 4e42735b88..b7c0b476fc 100644 --- a/lib/rbcodec/metadata/metadata.c +++ b/lib/rbcodec/metadata/metadata.c @@ -420,11 +420,12 @@ unsigned int probe_file_format(const char *filename) /* Get metadata for track - return false if parsing showed problems with the * file that would prevent playback. supply a filedescriptor <0 and the file will be opened * and closed automatically within the get_metadata call + * audio_fmt is AFMT_ enum provided by probe_file_format(trackname), * get_metadata_ex allows flags to change the way get_metadata behaves * METADATA_EXCLUDE_ID3_PATH won't copy filename path to the id3 path buffer * METADATA_CLOSE_FD_ON_EXIT closes the open filedescriptor on exit */ -bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int flags) +bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int audio_fmt, int flags) { bool success = true; const struct afmt_entry *entry; @@ -449,7 +450,7 @@ bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int fl } /* Take our best guess at the codec type based on file extension */ - id3->codectype = probe_file_format(trackname); + id3->codectype = audio_fmt; /* use probe_file_format(trackname); */ /* default values for embedded cuesheets */ id3->has_embedded_cuesheet = false; @@ -517,7 +518,7 @@ log_on_exit: bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) { - return get_metadata_ex(id3, fd, trackname, 0); + return get_metadata_ex(id3, fd, trackname, probe_file_format(trackname), 0); } #define MOVE_ENTRY(x) if (x) x += offset; diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h index 110bee1f7d..7688f858a0 100644 --- a/lib/rbcodec/metadata/metadata.h +++ b/lib/rbcodec/metadata/metadata.h @@ -328,9 +328,9 @@ struct mp3entry { bool is_asf_stream; }; -unsigned int probe_file_format(const char *filename); +unsigned int probe_file_format(const char *filename); /* returns audio_fmt */ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname); -bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int flags); +bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int audio_fmt, int flags); void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig); void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig); void wipe_mp3entry(struct mp3entry *id3); -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs