core/history: Move history queue into a new file
I think managing this separately from temporary queues will make the code simpler. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
460aeded4e
commit
77d4815eb6
|
@ -4,6 +4,7 @@
|
|||
#include <core/audio.h>
|
||||
extern "C" {
|
||||
#include <core/collection.h>
|
||||
#include <core/history.h>
|
||||
}
|
||||
#include <core/deck.h>
|
||||
#include <core/string.h>
|
||||
|
@ -144,7 +145,7 @@ void audio :: load_track(struct track *track)
|
|||
return;
|
||||
|
||||
_load_track(track, cur_driver->is_playing());
|
||||
queue_add(deck :: get_queue(), cur_track);
|
||||
queue_add(history_get_queue(), cur_track);
|
||||
}
|
||||
|
||||
struct track *audio :: current_track()
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
*/
|
||||
extern "C" {
|
||||
#include <core/collection.h>
|
||||
#include <core/history.h>
|
||||
}
|
||||
#include <core/deck.h>
|
||||
#include <core/file.h>
|
||||
|
||||
static std::list<TempQueue> queue_deck;
|
||||
static struct queue recent_queue;
|
||||
static struct file deck_file;
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@ void deck :: init(struct queue_ops *history_ops, struct queue_ops *temp_ops)
|
|||
bool upgraded = false;
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
queue_init(&recent_queue, Q_ENABLED | Q_REPEAT | Q_NO_SORT | Q_ADD_FRONT, history_ops);
|
||||
queue_init(history_get_queue(), Q_ENABLED | Q_REPEAT | Q_NO_SORT | Q_ADD_FRONT, history_ops);
|
||||
file_init(&deck_file, "deck", 1);
|
||||
|
||||
if (!file_open(&deck_file, OPEN_READ))
|
||||
|
@ -219,24 +219,20 @@ struct track *deck :: next()
|
|||
if (!track)
|
||||
track = queue_next(collection_get_queue());
|
||||
if (track) {
|
||||
queue_remove_all(&recent_queue, track);
|
||||
queue_add(&recent_queue, track);
|
||||
_q_iter_set(&recent_queue.q_tracks, &recent_queue.q_cur, 0);
|
||||
queue_remove_all(history_get_queue(), track);
|
||||
queue_add(history_get_queue(), track);
|
||||
_q_iter_set(&history_get_queue()->q_tracks,
|
||||
&history_get_queue()->q_cur, 0);
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
struct track *deck :: prev()
|
||||
{
|
||||
return queue_next(&recent_queue);
|
||||
return queue_next(history_get_queue());
|
||||
}
|
||||
|
||||
std::list<TempQueue> &deck :: get_queues()
|
||||
{
|
||||
return queue_deck;
|
||||
}
|
||||
|
||||
queue *deck :: get_queue()
|
||||
{
|
||||
return &recent_queue;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/history.h>
|
||||
|
||||
static struct queue history_queue;
|
||||
|
||||
|
||||
struct queue *history_get_queue()
|
||||
{
|
||||
return &history_queue;
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
extern "C" {
|
||||
#include <core/history.h>
|
||||
}
|
||||
#include <core/deck.h>
|
||||
#include <gui/tabs.h>
|
||||
#include <gui/queue/label.h>
|
||||
|
@ -11,7 +14,7 @@ private:
|
|||
HistoryLabel *history_label;
|
||||
|
||||
public:
|
||||
HistoryTab() : Tab(deck :: get_queue())
|
||||
HistoryTab() : Tab(history_get_queue())
|
||||
{
|
||||
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
|
||||
tab_builder->get_widget_derived("HistoryLabel", history_label);
|
||||
|
|
|
@ -110,11 +110,6 @@ namespace deck
|
|||
*/
|
||||
std::list<TempQueue> &get_queues();
|
||||
|
||||
/**
|
||||
* @return The queue of recent tracks.
|
||||
*/
|
||||
queue *get_queue();
|
||||
|
||||
};
|
||||
|
||||
#endif /* OCARINA_CORE_DECK_H */
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_CORE_HISTORY_H
|
||||
#define OCARINA_CORE_HISTORY_H
|
||||
|
||||
#include <core/queue.h>
|
||||
|
||||
/* Called to access the queue of recent tracks. */
|
||||
struct queue *history_get_queue();
|
||||
|
||||
#endif /* OCARINA_CORE_HISTORY_H */
|
|
@ -6,6 +6,7 @@ deck
|
|||
driver
|
||||
file
|
||||
filter
|
||||
history
|
||||
idle
|
||||
index
|
||||
playlist
|
||||
|
|
|
@ -40,6 +40,7 @@ res += SConscript("tags/Sconscript")
|
|||
res += [ CoreTest("queue") ]
|
||||
res += [ CoreTest("playlist") ]
|
||||
res += [ CoreTest("collection") ]
|
||||
res += [ CoreTest("history") ]
|
||||
res += [ CoreTest("deck") ]
|
||||
res += [ CoreTest("audio") ]
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
extern "C" {
|
||||
#include <core/collection.h>
|
||||
#include <core/filter.h>
|
||||
#include <core/history.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/tags/tags.h>
|
||||
}
|
||||
|
@ -104,7 +105,7 @@ static void test_create_mv_destroy()
|
|||
static void test_next_prev()
|
||||
{
|
||||
std::list<TempQueue>::iterator it = deck :: get_queues().begin();
|
||||
queue *q = deck :: get_queue();
|
||||
queue *q = history_get_queue();
|
||||
queue *q0 = deck :: get(0);
|
||||
queue *q1 = deck :: get(1);
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/history.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
struct queue *q = history_get_queue();
|
||||
|
||||
test_not_equal((void *)q, NULL);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("History Initialization", test_init),
|
||||
);
|
Loading…
Reference in New Issue