forked from len0rd/rockbox
plugins lib: use existing mp3info function
Change-Id: I88d3c04db5cbc0905153b0e616adb7a64afee707
This commit is contained in:
parent
1e678977f2
commit
8b95f2e758
5 changed files with 16 additions and 24 deletions
|
@ -20,27 +20,20 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "plugin.h"
|
#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 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));
|
rb->strlcpy(id3->path, file, sizeof(id3->path));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
(void) try_tagcache;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fd = rb->open(file, O_RDONLY);
|
return !rb->mp3info(id3, file);
|
||||||
if (fd >= 0)
|
|
||||||
{
|
|
||||||
if (rb->get_metadata(id3, fd, file))
|
|
||||||
ret = true;
|
|
||||||
rb->close(fd);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,6 @@
|
||||||
#ifndef ID3_H
|
#ifndef ID3_H
|
||||||
#define 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 */
|
#endif /* ID3_H */
|
||||||
|
|
|
@ -25,4 +25,4 @@ void init_mul_id3(void);
|
||||||
void collect_id3(struct mp3entry *id3, bool is_first_track);
|
void collect_id3(struct mp3entry *id3, bool is_first_track);
|
||||||
void write_id3_mul_tracks(struct mp3entry *id3);
|
void write_id3_mul_tracks(struct mp3entry *id3);
|
||||||
|
|
||||||
#endif /* MUL_ID3_H */
|
#endif /* MUL_ID3_H */
|
||||||
|
|
|
@ -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);
|
pf_idx.album_index[slide_index].artist_seek);
|
||||||
|
|
||||||
ret = rb->tagcache_get_next(&tcs) &&
|
ret = rb->tagcache_get_next(&tcs) &&
|
||||||
retrieve_id3(&id3, tcs.result, true) &&
|
retrieve_id3(&id3, tcs.result) &&
|
||||||
search_albumart_files(&id3, ":", buf, buflen);
|
search_albumart_files(&id3, ":", buf, buflen);
|
||||||
|
|
||||||
rb->tagcache_search_finish(&tcs);
|
rb->tagcache_search_finish(&tcs);
|
||||||
|
@ -3996,7 +3996,7 @@ static int show_id3_info(const char *selected_file)
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
file_name = i == 0 ? selected_file : get_track_filename(i);
|
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;
|
return 0;
|
||||||
|
|
||||||
if (is_multiple_tracks)
|
if (is_multiple_tracks)
|
||||||
|
@ -4347,7 +4347,7 @@ static void draw_album_text(void)
|
||||||
static void set_initial_slide(const char* selected_file)
|
static void set_initial_slide(const char* selected_file)
|
||||||
{
|
{
|
||||||
if (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) :
|
id3_get_index(&id3) :
|
||||||
pf_cfg.last_album);
|
pf_cfg.last_album);
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "lib/id3.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
#include "lib/mul_id3.h"
|
#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",
|
rb->snprintf(str_time, sizeof str_time, "%02d:%02d:%02d",
|
||||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
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;
|
props_type = PROPS_ID3;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -375,7 +374,7 @@ static bool determine_file_or_dir(void)
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
bool mul_id3_add(const char *file_name)
|
bool mul_id3_add(const char *file_name)
|
||||||
{
|
{
|
||||||
if (!retrieve_id3(&id3, file_name, false))
|
if (rb->mp3info(&id3, file_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
collect_id3(&id3, mul_id3_count == 0);
|
collect_id3(&id3, mul_id3_count == 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue