libsaria: Add songs to the queue
It takes a list of song ids and adds them to a deque. The UI can then iterate over each ID and query the size.
This commit is contained in:
parent
9739bdc76a
commit
6ef54e07c5
|
@ -8,6 +8,7 @@ enum callback_t {
|
|||
TRACK_LOADED,
|
||||
IDLE_TASK_QUEUED,
|
||||
LIBRARY_REFRESH,
|
||||
QUEUE_REFRESH,
|
||||
REFILTER,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef LIBSARIA_QUEUE_H
|
||||
#define LIBSARIA_QUEUE_H
|
||||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/model.h>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
|
@ -11,6 +11,8 @@ namespace libsaria
|
|||
{
|
||||
|
||||
void add_ids(list<ino_t> &);
|
||||
void for_each(SourceModel *);
|
||||
unsigned int size();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,15 +156,12 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
bool library::get_info(ino_t &id, void (*func)(Track &))
|
||||
TrackTag *library::get_info(ino_t &id)
|
||||
{
|
||||
list<TrackTag *>::iterator it;
|
||||
if (find_id(id, it)) {
|
||||
Track tag(*it);
|
||||
func(tag);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (find_id(id, it))
|
||||
return *it;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void library::next()
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
using namespace std;
|
||||
|
||||
#include <libsaria/queue.h>
|
||||
#include <libsaria/library.h>
|
||||
#include <libsaria/callback.h>
|
||||
|
||||
static deque<ino_t> playqueue;
|
||||
|
||||
|
@ -14,7 +16,23 @@ namespace libsaria
|
|||
{
|
||||
playqueue.insert(playqueue.end(), ids.begin(), ids.end());
|
||||
print("Queue size: ");
|
||||
println(playqueue.size());
|
||||
trigger_callback(QUEUE_REFRESH);
|
||||
}
|
||||
|
||||
void queue::for_each(SourceModel *model)
|
||||
{
|
||||
deque<ino_t>::iterator it;
|
||||
for (it = playqueue.begin(); it != playqueue.end(); it++)
|
||||
{
|
||||
TrackTag *tag = libsaria::library::get_info(*it);
|
||||
Track track = Track(tag);
|
||||
model->insert(track);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int queue::size()
|
||||
{
|
||||
return playqueue.size();
|
||||
}
|
||||
|
||||
} /* Namespace: libsaria */
|
||||
|
|
Loading…
Reference in New Issue