1
0
Fork 0
forked from len0rd/rockbox

plugins lib: use existing mp3info function

Change-Id: I88d3c04db5cbc0905153b0e616adb7a64afee707
This commit is contained in:
Christian Soffke 2023-03-26 19:11:46 +02:00
parent 1e678977f2
commit 8b95f2e758
5 changed files with 16 additions and 24 deletions

View file

@ -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);
}

View file

@ -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 */

View file

@ -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

View file

@ -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);