libsaria: Remove references to ino_t
I want to use sid_t instead. It's more obvious what it's used for.
This commit is contained in:
parent
f047c72521
commit
5f20899b14
|
@ -27,15 +27,15 @@ namespace libsaria
|
|||
string next_file();
|
||||
void add_path(string);
|
||||
void remove_path(string);
|
||||
void play_id(ino_t &);
|
||||
string find_filepath(ino_t &);
|
||||
TrackTag *get_info(ino_t &);
|
||||
void play_id(sid_t &);
|
||||
string find_filepath(sid_t &);
|
||||
TrackTag *get_info(sid_t &);
|
||||
void for_each(SourceModel *);
|
||||
void for_each_path(void (*)(struct PathInfo &));
|
||||
|
||||
unsigned int size();
|
||||
void filter(string &text);
|
||||
bool is_visible(ino_t &);
|
||||
bool is_visible(sid_t &);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef LIBSARIA_PATH_H
|
||||
#define LIBSARIA_PATH_H
|
||||
|
||||
#include <libsaria/track.h>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
@ -10,12 +12,12 @@ using namespace std;
|
|||
struct file
|
||||
{
|
||||
string name;
|
||||
ino_t d_ino;
|
||||
sid_t d_sid;
|
||||
};
|
||||
|
||||
void readdir(string, list<file> &, list<file> &);
|
||||
string get_saria_dir();
|
||||
void make_saria_dir();
|
||||
bool get_inode(string, ino_t &);
|
||||
bool get_inode(string, sid_t &);
|
||||
|
||||
#endif /* LIBSARIA_PATH_H */
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace libsaria
|
|||
namespace queue
|
||||
{
|
||||
|
||||
void add_ids(list<ino_t> &);
|
||||
void add_ids(list<sid_t> &);
|
||||
void for_each(SourceModel *);
|
||||
unsigned int size();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define LIBSARIA_TAGS_H
|
||||
|
||||
#include <libsaria/files.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
@ -23,7 +24,7 @@ class TrackTag
|
|||
int bitrate;
|
||||
int sample;
|
||||
int channels;
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
|
||||
list<string> title_words;
|
||||
list<string> artist_words;
|
||||
|
@ -35,12 +36,12 @@ class TrackTag
|
|||
public:
|
||||
TrackTag();
|
||||
TrackTag(const TrackTag &);
|
||||
TrackTag(string, ino_t);
|
||||
TrackTag(string, sid_t);
|
||||
TrackTag(InFile &);
|
||||
~TrackTag();
|
||||
void save(OutFile &);
|
||||
|
||||
ino_t get_inode();
|
||||
sid_t get_songid();
|
||||
unsigned int get_track();
|
||||
string get_title();
|
||||
string get_lenstr();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef LIBSARIA_TRACK_H
|
||||
#define LIBSARIA_TRACK_H
|
||||
|
||||
#include <libsaria/tags.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Set up song id type */
|
||||
typedef ino_t sid_t;
|
||||
|
||||
#include <libsaria/tags.h>
|
||||
|
||||
class Track
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <libsaria/audio.h>
|
||||
#include <libsaria/path.h>
|
||||
|
||||
static int current_inode(ino_t &inode)
|
||||
static int current_inode(sid_t &inode)
|
||||
{
|
||||
string file = libsaria::audio::get_current_file();
|
||||
if (file == "")
|
||||
|
@ -17,7 +17,7 @@ namespace libsaria
|
|||
|
||||
void current_track(void (*func)(Track &))
|
||||
{
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
TrackTag *tag;
|
||||
|
||||
if (current_inode(inode) < 0) {
|
||||
|
|
|
@ -12,26 +12,26 @@ using namespace std;
|
|||
|
||||
#define MAX_TRACKS 100
|
||||
|
||||
static map<string, set<ino_t> > substr_index;
|
||||
static set<ino_t> results;
|
||||
static map<string, set<sid_t> > substr_index;
|
||||
static set<sid_t> results;
|
||||
static string cur_filter;
|
||||
static bool filtered;
|
||||
|
||||
static void add_to_index(ino_t &inode, string &key)
|
||||
static void add_to_index(sid_t &inode, string &key)
|
||||
{
|
||||
map<string, set<ino_t> >::iterator it;
|
||||
map<string, set<sid_t> >::iterator it;
|
||||
|
||||
it = substr_index.find(key);
|
||||
if (it != substr_index.end())
|
||||
it->second.insert(inode);
|
||||
else {
|
||||
set<ino_t> to_insert;
|
||||
set<sid_t> to_insert;
|
||||
to_insert.insert(inode);
|
||||
substr_index.insert(pair<string, set<ino_t> >(key, to_insert));
|
||||
substr_index.insert(pair<string, set<sid_t> >(key, to_insert));
|
||||
}
|
||||
}
|
||||
|
||||
static void index_word(ino_t &inode, string &word)
|
||||
static void index_word(sid_t &inode, string &word)
|
||||
{
|
||||
string substr, key;
|
||||
|
||||
|
@ -44,7 +44,7 @@ static void index_word(ino_t &inode, string &word)
|
|||
}
|
||||
}
|
||||
|
||||
static void index_tag(ino_t &inode, list<string> *word_list)
|
||||
static void index_tag(sid_t &inode, list<string> *word_list)
|
||||
{
|
||||
list<string>::iterator it;
|
||||
for (it = word_list->begin(); it != word_list->end(); it++)
|
||||
|
@ -62,10 +62,10 @@ void IndexTask::index_track(TrackTag *tag)
|
|||
void IndexTask::run_task()
|
||||
{
|
||||
list<TrackTag *>::iterator it;
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
|
||||
for (it = track_list.begin(); it != track_list.end(); it++) {
|
||||
inode = (*it)->get_inode();
|
||||
inode = (*it)->get_songid();
|
||||
index_tag(inode, (*it)->get_title_words());
|
||||
index_tag(inode, (*it)->get_artist_words());
|
||||
index_tag(inode, (*it)->get_album_words());
|
||||
|
@ -97,10 +97,10 @@ static void reindex_path(list<TrackTag> *tag_list)
|
|||
* Thanks to: http://stackoverflow.com/questions/1773526/in-place-c-set-intersection
|
||||
* for the set intersection algorithm!
|
||||
*/
|
||||
static void inplace_intersect(set<ino_t> *inodes)
|
||||
static void inplace_intersect(set<sid_t> *inodes)
|
||||
{
|
||||
set<ino_t>::iterator it1 = results.begin();
|
||||
set<ino_t>::iterator it2 = inodes->begin();
|
||||
set<sid_t>::iterator it1 = results.begin();
|
||||
set<sid_t>::iterator it2 = inodes->begin();
|
||||
|
||||
while ( (it1 != results.end()) && (it2 != inodes->end()) ) {
|
||||
if (*it1 < *it2)
|
||||
|
@ -121,7 +121,7 @@ static void inplace_intersect(set<ino_t> *inodes)
|
|||
static void do_filter(list<string> &terms)
|
||||
{
|
||||
list<string>::iterator it;
|
||||
map<string, set<ino_t> >::iterator index_iter;
|
||||
map<string, set<sid_t> >::iterator index_iter;
|
||||
|
||||
for (it = terms.begin(); it != terms.end(); it++) {
|
||||
index_iter = substr_index.find(*it);
|
||||
|
@ -180,9 +180,9 @@ namespace libsaria
|
|||
return filtered;
|
||||
}
|
||||
|
||||
bool library::is_visible(ino_t &inode)
|
||||
bool library::is_visible(sid_t &inode)
|
||||
{
|
||||
set<ino_t>::iterator it;
|
||||
set<sid_t>::iterator it;
|
||||
|
||||
if (filtered == false)
|
||||
return true;
|
||||
|
@ -195,9 +195,9 @@ namespace libsaria
|
|||
return results.size();
|
||||
}
|
||||
|
||||
ino_t library::index_rand()
|
||||
sid_t library::index_rand()
|
||||
{
|
||||
set<ino_t>::iterator it = results.begin();
|
||||
set<sid_t>::iterator it = results.begin();
|
||||
unsigned int index = rand() % filter_size();
|
||||
|
||||
for (unsigned int i = 0; i < index; i++)
|
||||
|
|
|
@ -15,7 +15,7 @@ class LibraryPath
|
|||
string path;
|
||||
list<TrackTag> file_list;
|
||||
|
||||
list<TrackTag>::iterator find_id(ino_t &);
|
||||
list<TrackTag>::iterator find_id(sid_t &);
|
||||
|
||||
public:
|
||||
LibraryPath(string);
|
||||
|
@ -25,7 +25,7 @@ class LibraryPath
|
|||
list<TrackTag> *get_list();
|
||||
string get_path();
|
||||
void get_info(void (*)(struct libsaria::library::PathInfo &));
|
||||
void insert_track(ino_t &inode, TrackTag &);
|
||||
void insert_track(sid_t &inode, TrackTag &);
|
||||
void save(OutFile &);
|
||||
void update();
|
||||
unsigned int size();
|
||||
|
@ -75,7 +75,7 @@ namespace libsaria
|
|||
void reindex();
|
||||
bool is_filtered();
|
||||
unsigned int filter_size();
|
||||
ino_t index_rand();
|
||||
sid_t index_rand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,10 +63,10 @@ static bool compare_tracktags(TrackTag *one, TrackTag *two)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool find_id(ino_t &inode, list<TrackTag *>::iterator &it)
|
||||
static bool find_id(sid_t &inode, list<TrackTag *>::iterator &it)
|
||||
{
|
||||
for (it = play_list.begin(); it != play_list.end(); it++) {
|
||||
if ((*it)->get_inode() == inode)
|
||||
if ((*it)->get_songid() == inode)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -93,7 +93,7 @@ static void random_next()
|
|||
cur_track = play_list.begin();
|
||||
if (libsaria::library::is_filtered()) {
|
||||
println("Picking random track from index");
|
||||
ino_t inode = libsaria::library::index_rand();
|
||||
sid_t inode = libsaria::library::index_rand();
|
||||
libsaria::library::play_id(inode);
|
||||
} else {
|
||||
unsigned int index = rand() % play_list.size();
|
||||
|
@ -105,13 +105,13 @@ static void random_next()
|
|||
|
||||
static void sequential_next()
|
||||
{
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
do {
|
||||
cur_track++;
|
||||
println("Picking sequentially next track");
|
||||
if (cur_track == play_list.end())
|
||||
cur_track = play_list.begin();
|
||||
inode = (*cur_track)->get_inode();
|
||||
inode = (*cur_track)->get_songid();
|
||||
} while (!libsaria::library::is_visible(inode));
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
void library::play_id(ino_t &id)
|
||||
void library::play_id(sid_t &id)
|
||||
{
|
||||
list<TrackTag *>::iterator it;
|
||||
if (find_id(id, it)) {
|
||||
|
@ -157,7 +157,7 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
string library::find_filepath(ino_t &id)
|
||||
string library::find_filepath(sid_t &id)
|
||||
{
|
||||
list<TrackTag *>::iterator it;
|
||||
if (find_id(id, it))
|
||||
|
@ -165,7 +165,7 @@ namespace libsaria
|
|||
return "";
|
||||
}
|
||||
|
||||
TrackTag *library::get_info(ino_t &id)
|
||||
TrackTag *library::get_info(sid_t &id)
|
||||
{
|
||||
list<TrackTag *>::iterator it;
|
||||
if (find_id(id, it))
|
||||
|
|
|
@ -37,11 +37,11 @@ void LibraryPath::get_info(void (*info_func)(struct libsaria::library::PathInfo
|
|||
info_func(info);
|
||||
}
|
||||
|
||||
list<TrackTag>::iterator LibraryPath::find_id(ino_t &id)
|
||||
list<TrackTag>::iterator LibraryPath::find_id(sid_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
if (it->get_inode() == id)
|
||||
if (it->get_songid() == id)
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/tags.h>
|
||||
#include <libsaria/library.h>
|
||||
#include "library.h"
|
||||
|
||||
void LibraryPath::insert_track(ino_t &inode, TrackTag &tag)
|
||||
void LibraryPath::insert_track(sid_t &inode, TrackTag &tag)
|
||||
{
|
||||
if (find_id(inode) == file_list.end())
|
||||
file_list.push_back(tag);
|
||||
|
@ -31,8 +32,8 @@ ScanTask::~ScanTask()
|
|||
void ScanTask::tag_file(file filepath)
|
||||
{
|
||||
try {
|
||||
TrackTag tag(dir + "/" + filepath.name, filepath.d_ino);
|
||||
library->insert_track(filepath.d_ino, tag);
|
||||
TrackTag tag(dir + "/" + filepath.name, filepath.d_sid);
|
||||
library->insert_track(filepath.d_sid, tag);
|
||||
} catch (string message) {
|
||||
println(message);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ static void sort_entry(struct dirent *dirp, list<file> &files, list<file> &dirs)
|
|||
return;
|
||||
|
||||
entry.name = dirp->d_name;
|
||||
entry.d_ino = dirp->d_ino;
|
||||
entry.d_sid = dirp->d_ino;
|
||||
if (entry.name == "." || entry.name == "..")
|
||||
return;
|
||||
|
||||
|
@ -80,7 +80,7 @@ void make_saria_dir()
|
|||
mkdir(saria.c_str(), mode);
|
||||
}
|
||||
|
||||
bool get_inode(string filepath, ino_t &ino)
|
||||
bool get_inode(string filepath, sid_t &ino)
|
||||
{
|
||||
int err;
|
||||
struct stat stat;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/tags.h>
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/print.h>
|
||||
|
@ -36,7 +37,7 @@ TrackTag::TrackTag(const TrackTag &tag)
|
|||
album_words = tag.album_words;
|
||||
}
|
||||
|
||||
TrackTag::TrackTag(string file, ino_t ino)
|
||||
TrackTag::TrackTag(string file, sid_t ino)
|
||||
{
|
||||
Tag *tag;
|
||||
AudioProperties *prop;
|
||||
|
@ -132,7 +133,7 @@ void TrackTag::format_tags()
|
|||
libsaria::format_text(album, album_words);
|
||||
}
|
||||
|
||||
ino_t TrackTag::get_inode()
|
||||
sid_t TrackTag::get_songid()
|
||||
{
|
||||
return inode;
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ using namespace std;
|
|||
#include <libsaria/library.h>
|
||||
#include <libsaria/callback.h>
|
||||
|
||||
static deque<ino_t> playqueue;
|
||||
static deque<sid_t> playqueue;
|
||||
|
||||
static void pop_queue(ino_t &inode)
|
||||
static void pop_queue(sid_t &inode)
|
||||
{
|
||||
inode = playqueue.front();
|
||||
playqueue.pop_front();
|
||||
|
@ -19,7 +19,7 @@ static void pop_queue(ino_t &inode)
|
|||
namespace libsaria
|
||||
{
|
||||
|
||||
void queue::add_ids(list<ino_t> &ids)
|
||||
void queue::add_ids(list<sid_t> &ids)
|
||||
{
|
||||
playqueue.insert(playqueue.end(), ids.begin(), ids.end());
|
||||
println("Queue size: %d", playqueue.size());
|
||||
|
@ -28,7 +28,7 @@ namespace libsaria
|
|||
|
||||
void queue::for_each(SourceModel *model)
|
||||
{
|
||||
deque<ino_t>::iterator it;
|
||||
deque<sid_t>::iterator it;
|
||||
for (it = playqueue.begin(); it != playqueue.end(); it++)
|
||||
{
|
||||
TrackTag *tag = libsaria::library::get_info(*it);
|
||||
|
@ -44,14 +44,14 @@ namespace libsaria
|
|||
|
||||
string queue::next_file()
|
||||
{
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
pop_queue(inode);
|
||||
return library::find_filepath(inode);
|
||||
}
|
||||
|
||||
void queue::next()
|
||||
{
|
||||
ino_t inode;
|
||||
sid_t inode;
|
||||
pop_queue(inode);
|
||||
library::play_id(inode);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ Track::~Track()
|
|||
sid_t Track::get_songid()
|
||||
{
|
||||
if (tags)
|
||||
return tags->get_inode();
|
||||
return tags->get_songid();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue