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-8b95f2e7585e04406db66935fa514a45afa0cbd8.tar.gz rockbox-8b95f2e7585e04406db66935fa514a45afa0cbd8.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 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | 22 | ||
23 | bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache) | 23 | /* Fills mp3entry with metadata retrieved from RAM, if possible, or by reading from |
24 | * the file directly. Note that the tagcache only stores a subset of metadata and | ||
25 | * will thus not return certain properties of the file, such as frequency, size, or | ||
26 | * codec. | ||
27 | */ | ||
28 | bool retrieve_id3(struct mp3entry *id3, const char* file) | ||
24 | { | 29 | { |
25 | bool ret = false; | ||
26 | int fd; | ||
27 | |||
28 | #if defined (HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | 30 | #if defined (HAVE_TAGCACHE) && defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) |
29 | if (try_tagcache && rb->tagcache_fill_tags(id3, file)) | 31 | if (rb->tagcache_fill_tags(id3, file)) |
30 | { | 32 | { |
31 | rb->strlcpy(id3->path, file, sizeof(id3->path)); | 33 | rb->strlcpy(id3->path, file, sizeof(id3->path)); |
32 | return true; | 34 | return true; |
33 | } | 35 | } |
34 | #else | ||
35 | (void) try_tagcache; | ||
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | fd = rb->open(file, O_RDONLY); | 38 | return !rb->mp3info(id3, file); |
39 | if (fd >= 0) | ||
40 | { | ||
41 | if (rb->get_metadata(id3, fd, file)) | ||
42 | ret = true; | ||
43 | rb->close(fd); | ||
44 | } | ||
45 | return ret; | ||
46 | } | 39 | } |
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 @@ | |||
21 | #ifndef ID3_H | 21 | #ifndef ID3_H |
22 | #define ID3_H | 22 | #define ID3_H |
23 | 23 | ||
24 | bool retrieve_id3(struct mp3entry *id3, const char* file, bool try_tagcache); | 24 | bool retrieve_id3(struct mp3entry *id3, const char* file); |
25 | 25 | ||
26 | #endif /* ID3_H */ \ No newline at end of file | 26 | #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); | |||
25 | void collect_id3(struct mp3entry *id3, bool is_first_track); | 25 | void collect_id3(struct mp3entry *id3, bool is_first_track); |
26 | void write_id3_mul_tracks(struct mp3entry *id3); | 26 | void write_id3_mul_tracks(struct mp3entry *id3); |
27 | 27 | ||
28 | #endif /* MUL_ID3_H */ \ No newline at end of file | 28 | #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, | |||
2086 | pf_idx.album_index[slide_index].artist_seek); | 2086 | pf_idx.album_index[slide_index].artist_seek); |
2087 | 2087 | ||
2088 | ret = rb->tagcache_get_next(&tcs) && | 2088 | ret = rb->tagcache_get_next(&tcs) && |
2089 | retrieve_id3(&id3, tcs.result, true) && | 2089 | retrieve_id3(&id3, tcs.result) && |
2090 | search_albumart_files(&id3, ":", buf, buflen); | 2090 | search_albumart_files(&id3, ":", buf, buflen); |
2091 | 2091 | ||
2092 | rb->tagcache_search_finish(&tcs); | 2092 | rb->tagcache_search_finish(&tcs); |
@@ -3996,7 +3996,7 @@ static int show_id3_info(const char *selected_file) | |||
3996 | i = 0; | 3996 | i = 0; |
3997 | do { | 3997 | do { |
3998 | file_name = i == 0 ? selected_file : get_track_filename(i); | 3998 | file_name = i == 0 ? selected_file : get_track_filename(i); |
3999 | if (!retrieve_id3(&id3, file_name, false)) | 3999 | if (rb->mp3info(&id3, file_name)) |
4000 | return 0; | 4000 | return 0; |
4001 | 4001 | ||
4002 | if (is_multiple_tracks) | 4002 | if (is_multiple_tracks) |
@@ -4347,7 +4347,7 @@ static void draw_album_text(void) | |||
4347 | static void set_initial_slide(const char* selected_file) | 4347 | static void set_initial_slide(const char* selected_file) |
4348 | { | 4348 | { |
4349 | if (selected_file) | 4349 | if (selected_file) |
4350 | set_current_slide(retrieve_id3(&id3, selected_file, true) ? | 4350 | set_current_slide(retrieve_id3(&id3, selected_file) ? |
4351 | id3_get_index(&id3) : | 4351 | id3_get_index(&id3) : |
4352 | pf_cfg.last_album); | 4352 | pf_cfg.last_album); |
4353 | else | 4353 | 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 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/id3.h" | ||
23 | 22 | ||
24 | #ifdef HAVE_TAGCACHE | 23 | #ifdef HAVE_TAGCACHE |
25 | #include "lib/mul_id3.h" | 24 | #include "lib/mul_id3.h" |
@@ -127,7 +126,7 @@ static bool file_properties(const char* selected_file) | |||
127 | rb->snprintf(str_time, sizeof str_time, "%02d:%02d:%02d", | 126 | rb->snprintf(str_time, sizeof str_time, "%02d:%02d:%02d", |
128 | tm.tm_hour, tm.tm_min, tm.tm_sec); | 127 | tm.tm_hour, tm.tm_min, tm.tm_sec); |
129 | 128 | ||
130 | if (retrieve_id3(&id3, selected_file, false)) | 129 | if (!rb->mp3info(&id3, selected_file)) |
131 | props_type = PROPS_ID3; | 130 | props_type = PROPS_ID3; |
132 | found = true; | 131 | found = true; |
133 | break; | 132 | break; |
@@ -375,7 +374,7 @@ static bool determine_file_or_dir(void) | |||
375 | #ifdef HAVE_TAGCACHE | 374 | #ifdef HAVE_TAGCACHE |
376 | bool mul_id3_add(const char *file_name) | 375 | bool mul_id3_add(const char *file_name) |
377 | { | 376 | { |
378 | if (!retrieve_id3(&id3, file_name, false)) | 377 | if (rb->mp3info(&id3, file_name)) |
379 | return false; | 378 | return false; |
380 | 379 | ||
381 | collect_id3(&id3, mul_id3_count == 0); | 380 | collect_id3(&id3, mul_id3_count == 0); |