mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
rework my previous commit (FS#8008) to be able to work for any of the strings in the id3 info struct, new ones need to be added to tagtree.c and tagnavi.config
*currently available tags are* #title# #artist# #album# #genre# #composer# #albumartist# and #directory# git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15358 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c985903084
commit
75eff7af5e
3 changed files with 57 additions and 24 deletions
|
@ -110,10 +110,12 @@ struct tagcache_stat {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum source_type {source_constant, source_input,
|
enum source_type {source_constant, source_input,
|
||||||
source_current_artist, source_current_album};
|
source_current_path, /* has different handling to _id3
|
||||||
|
so it has to be seperate */
|
||||||
#define SOURCE_CURRENT_ARTIST "#artist#"
|
source_current_id3 /* dont add items after this.
|
||||||
#define SOURCE_CURRENT_ALBUM "#album#"
|
it is used as an index
|
||||||
|
into id3_to_search_mapping */
|
||||||
|
};
|
||||||
|
|
||||||
struct tagcache_search_clause
|
struct tagcache_search_clause
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,7 @@
|
||||||
%menu_start "same" "Same as current"
|
%menu_start "same" "Same as current"
|
||||||
"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
|
"Artist" -> album ? artist = "#artist#" -> title = "fmt_title"
|
||||||
"Album" -> title = "fmt_title" ? album = "#album#"
|
"Album" -> title = "fmt_title" ? album = "#album#"
|
||||||
|
"Directory" -> filename ? filename ~ "#directory#"
|
||||||
|
|
||||||
# Define the runtime sub menu
|
# Define the runtime sub menu
|
||||||
%menu_start "runtime" "Play history"
|
%menu_start "runtime" "Play history"
|
||||||
|
|
|
@ -53,7 +53,17 @@ static int tagtree_play_folder(struct tree_context* c);
|
||||||
|
|
||||||
#define SEARCHSTR_SIZE 128
|
#define SEARCHSTR_SIZE 128
|
||||||
static char searchstring[SEARCHSTR_SIZE];
|
static char searchstring[SEARCHSTR_SIZE];
|
||||||
|
static const struct id3_to_search_mapping {
|
||||||
|
char *string;
|
||||||
|
size_t id3_offset;
|
||||||
|
} id3_to_search_mapping[] = {
|
||||||
|
{ "#title#", offsetof(struct mp3entry, title) },
|
||||||
|
{ "#artist#", offsetof(struct mp3entry, artist) },
|
||||||
|
{ "#album#", offsetof(struct mp3entry, album) },
|
||||||
|
{ "#genre#", offsetof(struct mp3entry, genre_string) },
|
||||||
|
{ "#composer#", offsetof(struct mp3entry, composer) },
|
||||||
|
{ "#albumartist#", offsetof(struct mp3entry, albumartist) },
|
||||||
|
};
|
||||||
enum variables {
|
enum variables {
|
||||||
var_sorttype = 100,
|
var_sorttype = 100,
|
||||||
var_limit,
|
var_limit,
|
||||||
|
@ -296,12 +306,25 @@ static bool read_clause(struct tagcache_search_clause *clause)
|
||||||
|
|
||||||
if (*(clause->str) == '\0')
|
if (*(clause->str) == '\0')
|
||||||
clause->source = source_input;
|
clause->source = source_input;
|
||||||
else if (!strcasecmp(clause->str, SOURCE_CURRENT_ALBUM))
|
else if (!strcasecmp(clause->str, "#directory#"))
|
||||||
clause->source = source_current_album;
|
clause->source = source_current_path;
|
||||||
else if (!strcasecmp(clause->str, SOURCE_CURRENT_ARTIST))
|
else
|
||||||
clause->source = source_current_artist;
|
{
|
||||||
|
unsigned int i;
|
||||||
|
bool found = false;
|
||||||
|
for (i=0; !found && i<ARRAYLEN(id3_to_search_mapping); i++)
|
||||||
|
{
|
||||||
|
if (!strcasecmp(clause->str, id3_to_search_mapping[i].string))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
|
clause->source = source_current_id3+i;
|
||||||
else
|
else
|
||||||
clause->source = source_constant;
|
clause->source = source_constant;
|
||||||
|
}
|
||||||
|
|
||||||
if (tagcache_is_numeric_tag(clause->tag))
|
if (tagcache_is_numeric_tag(clause->tag))
|
||||||
{
|
{
|
||||||
|
@ -1404,19 +1427,26 @@ int tagtree_enter(struct tree_context* c)
|
||||||
|
|
||||||
id3 = audio_current_track();
|
id3 = audio_current_track();
|
||||||
|
|
||||||
if ((source == source_current_artist) &&
|
if (source == source_current_path && id3)
|
||||||
(id3) && (id3->artist))
|
|
||||||
{
|
{
|
||||||
strncpy(searchstring, id3->artist, SEARCHSTR_SIZE);
|
char *e;
|
||||||
searchstring[SEARCHSTR_SIZE-1] = '\0';
|
strncpy(searchstring, id3->path, SEARCHSTR_SIZE);
|
||||||
|
e = strrchr(searchstring, '/');
|
||||||
|
if (e)
|
||||||
|
*e = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((source == source_current_album) &&
|
if (source >= source_current_id3 && id3)
|
||||||
(id3) && (id3->album))
|
|
||||||
{
|
{
|
||||||
strncpy(searchstring, id3->album, SEARCHSTR_SIZE);
|
int i = source-source_current_id3;
|
||||||
|
int offset = id3_to_search_mapping[i].id3_offset;
|
||||||
|
char **src = (char**)((char*)id3 + offset);
|
||||||
|
if (*src)
|
||||||
|
{
|
||||||
|
strncpy(searchstring, *src, SEARCHSTR_SIZE);
|
||||||
searchstring[SEARCHSTR_SIZE-1] = '\0';
|
searchstring[SEARCHSTR_SIZE-1] = '\0';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((source == source_input) || (*searchstring=='\0'))
|
if((source == source_input) || (*searchstring=='\0'))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue