libsaria: Find tags for songs not in the library

I always want to find tags if it's possible.  Since I already have a way
to find the tags, it's fairly simple to tag a random file and pass the
result back to the UI.
This commit is contained in:
Bryan Schumaker 2011-10-29 16:24:57 -04:00
parent 049f91e514
commit 0da84e8151
3 changed files with 14 additions and 4 deletions

View File

@ -26,7 +26,7 @@ namespace libsaria
void add_path(string);
void remove_path(string);
void play_id(ino_t &);
void get_info(ino_t &, void(*)(Track &));
bool get_info(ino_t &, void(*)(Track &));
void for_each(SourceModel *);
void for_each_path(void (*)(struct PathInfo &));

View File

@ -18,12 +18,18 @@ namespace libsaria
void current_track(void (*func)(Track &))
{
ino_t inode;
if (current_inode(inode) < 0) {
Track blank;
func(blank);
return;
}
library::get_info(inode, func);
if (!library::get_info(inode, func)) {
TrackTag tag(libsaria::audio::get_current_file());
Track track(inode, &tag);
func(track);
}
}
};

View File

@ -98,13 +98,17 @@ namespace libsaria
}
}
void library::get_info(ino_t &id, void (*func)(Track &))
bool library::get_info(ino_t &id, void (*func)(Track &))
{
bool found = false;
map<string, LibraryPath>::iterator it;
for (it = path_map.begin(); it != path_map.end(); it++) {
if (it->second.get_info_id(id, func) == true)
if (it->second.get_info_id(id, func) == true) {
found = true;
break;
}
}
return found;
}
unsigned int library::size()