Lookup by id will be slighly slower, but now I will have one list for each path that can be merged together and sorted to represent the library. This sounds like a good tradeoff to me, especially since I can store an iterator to the current track when deciding what to play next. This will give me much faster access to song for the current track.
36 lines
596 B
C++
36 lines
596 B
C++
|
|
#include <libsaria/libsaria.h>
|
|
#include <libsaria/library.h>
|
|
#include <libsaria/audio.h>
|
|
#include <libsaria/path.h>
|
|
|
|
static int current_inode(ino_t &inode)
|
|
{
|
|
string file = libsaria::audio::get_current_file();
|
|
if (file == "")
|
|
return false;
|
|
return get_inode(file, inode);
|
|
}
|
|
|
|
namespace libsaria
|
|
{
|
|
|
|
void current_track(void (*func)(Track &))
|
|
{
|
|
ino_t inode;
|
|
|
|
if (current_inode(inode) < 0) {
|
|
Track blank;
|
|
func(blank);
|
|
return;
|
|
}
|
|
|
|
if (!library::get_info(inode, func)) {
|
|
TrackTag tag(libsaria::audio::get_current_file(), inode);
|
|
Track track(&tag);
|
|
func(track);
|
|
}
|
|
}
|
|
|
|
};
|