diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2023-03-26 19:11:46 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2023-04-05 11:27:25 -0400 |
commit | 8b95f2e7585e04406db66935fa514a45afa0cbd8 (patch) | |
tree | be67fb64a4aef24b0af94408117df1b6ddfad9e8 | |
parent | 1e678977f2841236b8a3e1b01f28a8dd73ba899b (diff) | |
download | rockbox-8b95f2e758.tar.gz rockbox-8b95f2e758.zip |
plugins lib: use existing mp3info function
Change-Id: I88d3c04db5cbc0905153b0e616adb7a64afee707
-rw-r--r-- | apps/plugins/lib/id3.c | 23 | ||||
-rw-r--r-- | apps/plugins/lib/id3.h | 4 | ||||
-rw-r--r-- | apps/plugins/lib/mul_id3.h | 2 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 6 | ||||
-rw-r--r-- | apps/plugins/properties.c | 5 |
5 files changed, 16 insertions, 24 deletions
diff --git a/apps/plugins/lib/id3.c b/apps/plugins/lib/id3.c index 0ce1736ffe..b0202b1d9c 100644 --- a/apps/plugins/lib/id3.c +++ b/apps/plugins/lib/id3.c @@ -20,27 +20,20 @@ ****************************************************************************/ #include "plugin.h" -bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache) +/* Fills mp3entry with metadata retrieved from RAM, if possible, or by reading from + * the file directly. Note that the tagcache only stores a subset of metadata and + * will thus not return certain properties of the file, such as frequency, size, or + * codec. + */ +bool retrieve_id3(struct mp3entry *id3, const char* file) { - bool ret = false; - int fd; - #if defined (HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) - if (try_tagcache && rb->tagcache_fill_tags(id3, file)) + if (rb->tagcache_fill_tags(id3, file)) { rb->strlcpy(id3->path, file, sizeof(id3->path)); return true; } -#else - (void) try_tagcache; #endif - fd = rb->open(file, O_RDONLY); - if (fd >= 0) - { - if (rb->get_metadata(id3, fd, file)) - ret = true; - rb->close(fd); - } - return ret; + return !rb->mp3info(id3, file); } diff --git a/apps/plugins/lib/id3.h b/apps/plugins/lib/id3.h index 292556d0c4..6ae1688798 100644 --- a/apps/plugins/lib/id3.h +++ b/apps/plugins/lib/id3.h @@ -21,6 +21,6 @@ #ifndef ID3_H #define ID3_H -bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache); +bool retrieve_id3(struct mp3entry *id3, const char* file); -#endif /* ID3_H */
\ No newline at end of file +#endif /* ID3_H */ diff --git a/apps/plugins/lib/mul_id3.h b/apps/plugins/lib/mul_id3.h index 71da10e87e..40d7fa7822 100644 --- a/apps/plugins/lib/mul_id3.h +++ b/apps/plugins/lib/mul_id3.h @@ -25,4 +25,4 @@ void init_mul_id3(void); void collect_id3(struct mp3entry *id3, bool is_first_track); void write_id3_mul_tracks(struct mp3entry *id3); -#endif /* MUL_ID3_H */
\ No newline at end of file +#endif /* MUL_ID3_H */ diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 67c26a7dc8..b5ea0af9ae 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -2086,7 +2086,7 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, pf_idx.album_index[slide_index].artist_seek); ret = rb->tagcache_get_next(&tcs) && - retrieve_id3(&id3, tcs.result, true) && + retrieve_id3(&id3, tcs.result) && search_albumart_files(&id3, ":", buf, buflen); rb->tagcache_search_finish(&tcs); @@ -3996,7 +3996,7 @@ static int show_id3_info(const char *selected_file) i = 0; do { file_name = i == 0 ? selected_file : get_track_filename(i); - if (!retrieve_id3(&id3, file_name, false)) + if (rb->mp3info(&id3, file_name)) return 0; if (is_multiple_tracks) @@ -4347,7 +4347,7 @@ static void draw_album_text(void) static void set_initial_slide(const char* selected_file) { if (selected_file) - set_current_slide(retrieve_id3(&id3, selected_file, true) ? + set_current_slide(retrieve_id3(&id3, selected_file) ? id3_get_index(&id3) : pf_cfg.last_album); else diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 7dacda3579..27bfe9181a 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -19,7 +19,6 @@ * ****************************************************************************/ #include "plugin.h" -#include "lib/id3.h" #ifdef HAVE_TAGCACHE #include "lib/mul_id3.h" @@ -127,7 +126,7 @@ static bool file_properties(const char* selected_file) rb->snprintf(str_time, sizeof str_time, "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); - if (retrieve_id3(&id3, selected_file, false)) + if (!rb->mp3info(&id3, selected_file)) props_type = PROPS_ID3; found = true; break; @@ -375,7 +374,7 @@ static bool determine_file_or_dir(void) #ifdef HAVE_TAGCACHE bool mul_id3_add(const char *file_name) { - if (!retrieve_id3(&id3, file_name, false)) + if (rb->mp3info(&id3, file_name)) return false; collect_id3(&id3, mul_id3_count == 0); |