deck: Update the deck design for a new implementation
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
a385727206
commit
b6156bab11
119
DESIGN
119
DESIGN
|
@ -1086,7 +1086,7 @@ Library:
|
|||
library path will have its tracks removed from the
|
||||
LibraryQueue.
|
||||
|
||||
void library :: get_queue();
|
||||
Queue *library :: get_queue();
|
||||
Return the LibraryQueue to the caller.
|
||||
|
||||
|
||||
|
@ -1173,75 +1173,98 @@ Playlist:
|
|||
|
||||
|
||||
|
||||
Deck:
|
||||
The deck is used to hold temporary queues created by the user. This
|
||||
layer is also in charge of maintaining a "recently played" queue of
|
||||
tracks.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Deck: (lib/deck.cpp)
|
||||
The playqueue deck is used to hold the temporary playqueues created by
|
||||
the user.
|
||||
|
||||
This module also controls the library playqueue, which should be updated
|
||||
using the on_library_track_add() and on_library_track_del() callback
|
||||
functions. The library playqueue will always have PQ_ENABLED and
|
||||
PQ_REPEAT set. This playlist will default to PQ_RANDOM unset.
|
||||
The deck will be saved to the file "deck". When upgrading from file
|
||||
version V0 to V1, use the saved random flag and sort order to set up
|
||||
the library_q.
|
||||
|
||||
- Deck:
|
||||
list<Playqueue> deck;
|
||||
Playqueue library_pq;
|
||||
list<Queue> deck;
|
||||
|
||||
File << library_pq.random << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[N] << endl;
|
||||
V0:
|
||||
File << library_q.random << library_q.sort_order().size();
|
||||
File << lib12order()[N].field << lib12order()[N].ascending;
|
||||
File << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[N] << endl;
|
||||
|
||||
V1:
|
||||
File << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[1] << endl;
|
||||
|
||||
- RecentQueue:
|
||||
class RecentQueue : public Queue {
|
||||
public:
|
||||
RecentQueue();
|
||||
unsigned int add(Track *);
|
||||
};
|
||||
|
||||
- RecentQueue API:
|
||||
RecentQueue :: RecentQueue();
|
||||
Initialize a Queue with the flags Q_ENABLED, Q_REPEAT, and
|
||||
Q_NO_SORT set.
|
||||
|
||||
unsigned int RecentQueue :: add(Track *track);
|
||||
The RecentQueue is designed to be a uniqueue queue that displays
|
||||
the most recent tracks first.
|
||||
|
||||
del(track);
|
||||
_cur = 0;
|
||||
return _add_at(track, 0);
|
||||
|
||||
- API
|
||||
void deck :: init();
|
||||
Set up callbacks used by the library.
|
||||
Read the deck file from disk and restore the queues.
|
||||
|
||||
void deck :: read(File &);
|
||||
void deck :: write(File &);
|
||||
Read or write the playqueue file. This will be called
|
||||
from the audio layer to store state.
|
||||
|
||||
Playqueue *deck :: create();
|
||||
Adds a new playqueue to the end of the deck and returns a
|
||||
pointer to it.
|
||||
Queue *deck :: create(bool random);
|
||||
Adds a new queue to the end of the deck and return a pointer
|
||||
to it. Save the deck to disk.
|
||||
|
||||
void deck :: remove(N);
|
||||
Remove playqueue N from the deck.
|
||||
void deck :: destroy(Queue *queue);
|
||||
Remove the requested queue from the deck and trigger the
|
||||
on_pq_removed() callback. Save the deck to disk.
|
||||
|
||||
Playqueue *deck :: get(N);
|
||||
Return playqueue N from the deck.
|
||||
void deck :: add(Track *track, Queue *queue);
|
||||
Add the requested track to the requested queue. Save the deck
|
||||
to disk.
|
||||
|
||||
void deck :: move(M, N);
|
||||
Move playqueue at index M to index N.
|
||||
void deck :: remove(Track *track, Queue *queue);
|
||||
Remove the requested track from the requested queue. Save the
|
||||
deck to disk.
|
||||
|
||||
unsigned int deck :: next();
|
||||
Iterate through the deck until you find a playqueue with the
|
||||
flag PQ_ENABLED set. Call next() on this playqueue and return
|
||||
the result.
|
||||
void deck :: move(Queue *queue, unsigned int pos);
|
||||
Move the queue to the new location in the deck. Save the deck
|
||||
to disk.
|
||||
|
||||
If the playqueue is empty after calling next(), remove it from
|
||||
the deck.
|
||||
Track *deck :: next();
|
||||
Find the first enabled queue on the deck and return the track
|
||||
given by queue->next().
|
||||
|
||||
If there are no playqueues on the deck, play a song from the
|
||||
library playqueue.
|
||||
If the queue is empty after calling next(), call destroy() to
|
||||
remove it from the list.
|
||||
|
||||
If there are no playable IDs, throw -EEXIST.
|
||||
If there are no enabled queues, return a track from the library
|
||||
queue. If the library queue is empty, return NULL.
|
||||
|
||||
Save the deck before returning.
|
||||
|
||||
list<Queue> &deck :: get_queues();
|
||||
Return the list of queues to the caller.
|
||||
|
||||
Queue *deck :: get_queue();
|
||||
Return the RecentQueue to the caller.
|
||||
|
||||
void deck :: reset();
|
||||
This function only exists if CONFIG_TEST is enabled. Erase
|
||||
all the playqueue information and reset the deck list.
|
||||
|
||||
void deck :: print_info();
|
||||
This function only exists if CONFIG_TEST is enabled. Print
|
||||
out helpful stats about the current state of the playqueue deck.
|
||||
|
||||
Playqueue *deck :: get_library_pq();
|
||||
Return the library playqueue.
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue