design: Rename a few subsystems
- Playlist -> playqueue. Playqueue sounds more temporary, which better represents how I intend this code to be used. - Groups -> playlist. A playlist is the accepted term for what I am trying to create here. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
31e6bcef3b
commit
f7a7710482
124
design.txt
124
design.txt
|
@ -175,6 +175,7 @@ On-disk files: (lib/file.cpp)
|
|||
XDG_{CONFIG|DATA}_HOME/ocarina-test/filepath
|
||||
$HOME/.ocarina/
|
||||
$HOME/.ocarina-debug/
|
||||
$HOME/.ocarina-test/
|
||||
|
||||
If filepath is an empty string, set the file hint to
|
||||
FILE_TYPE_INVALID and do not set the filepath field.
|
||||
|
@ -317,12 +318,12 @@ Database: (lib/database.cpp)
|
|||
Clear the database contents in-memory, but do NOT write
|
||||
to disk.
|
||||
|
||||
void Database :: print()
|
||||
void Database :: print();
|
||||
This function exists only If CONFIG_TEST is enabled.
|
||||
Following a similar format for writing to disk, print the
|
||||
database to the console in a human-readable format.
|
||||
|
||||
void Database :: print_keys()
|
||||
void Database :: print_keys();
|
||||
This function exists only if CONFIG_TEST is enabled.
|
||||
Print out the collected primary keys in the database.
|
||||
|
||||
|
@ -419,42 +420,8 @@ Filter: (lib/filter.cpp)
|
|||
Print cache hit and size information.
|
||||
|
||||
void filter :: get_index();
|
||||
This function only exists if CONFIG_TEST is enabled.
|
||||
Return the index storing all the filter data.
|
||||
(Only available if -DCONFIG_TEST is set)
|
||||
|
||||
|
||||
|
||||
Playlists: (lib/playlist.cpp)
|
||||
Playlists are going to be a new feature in Ocarina 6 and can compare
|
||||
directly to Gmail-style labels. Ocarina 6.0 will support two different
|
||||
playlists that the user can add songs to: banned and favorites.
|
||||
|
||||
Future releases will add support for more playlists.
|
||||
|
||||
- Database:
|
||||
Database<database :: IndexEntry> playlist_db
|
||||
|
||||
- Default playlists:
|
||||
Favorites:
|
||||
The user will add music they really like to this playlist.
|
||||
Banned:
|
||||
The user should add music they do not like to this playlist.
|
||||
Tracks should be removed from the Library playlist when they
|
||||
are banned and added back to the playlist when they are
|
||||
un-banned.
|
||||
|
||||
- API
|
||||
void playlist :: add(name, track_id)
|
||||
playlist_idx.insert(name, track_id);
|
||||
|
||||
void playlist :: del(name, track_id)
|
||||
playlist_idx.delete(name, track_id)
|
||||
|
||||
void void playlist :: list(list<string> &);
|
||||
return playlist_idx.keys();
|
||||
|
||||
void playlist :: get_tracks(name):
|
||||
return playlist_idx[name]
|
||||
|
||||
|
||||
|
||||
|
@ -506,7 +473,7 @@ Idle queue: (lib/idle.cpp)
|
|||
static inline void idle :: schedule(void (*)(T &), T);
|
||||
Create a new IdleTask to run the function later.
|
||||
|
||||
bool idle :: run_task()
|
||||
bool idle :: run_task();
|
||||
If there are tasks on the queue:
|
||||
run the next task
|
||||
scheduled++
|
||||
|
@ -517,13 +484,47 @@ Idle queue: (lib/idle.cpp)
|
|||
scheduled = 0
|
||||
return false
|
||||
|
||||
float idle :: get_progress()
|
||||
float idle :: get_progress();
|
||||
Return (serviced / queued) to the caller. If there are no
|
||||
tasks, return 1.0 to indicate that the queue is finished (and
|
||||
to avoid a divide-by-zero error).
|
||||
|
||||
|
||||
|
||||
Playlists: (lib/playlist.cpp)
|
||||
Playlists are going to be a new feature in Ocarina 6 and can compare
|
||||
directly to Gmail-style labels. Ocarina 6.0 will support two different
|
||||
playlists that the user can add songs to: banned and favorites.
|
||||
|
||||
Future releases will add support for more playlists.
|
||||
|
||||
- Database:
|
||||
Database<database :: IndexEntry> playlist_db
|
||||
|
||||
- Default playlists:
|
||||
Favorites:
|
||||
The user will add music they really like to this playlist.
|
||||
Banned:
|
||||
The user should add music they do not like to this playlist.
|
||||
Tracks should be removed from the Library playlist when they
|
||||
are banned and added back to the playlist when they are
|
||||
un-banned.
|
||||
|
||||
- API
|
||||
void playlist :: add(name, track_id);
|
||||
playlist_idx.insert(name, track_id);
|
||||
|
||||
void playlist :: del(name, track_id);
|
||||
playlist_idx.delete(name, track_id)
|
||||
|
||||
void void playlist :: list(list<string> &);
|
||||
return playlist_idx.keys();
|
||||
|
||||
void playlist :: get_tracks(name);
|
||||
return playlist_idx[name]
|
||||
|
||||
|
||||
|
||||
Library: (lib/library.cpp)
|
||||
The library manages databases containing track information added by the
|
||||
user. Ocarina 6 splits the library into multiple database tables for
|
||||
|
@ -628,7 +629,6 @@ Library: (lib/library.cpp)
|
|||
Database<library :: Track> track_db(track.db);
|
||||
|
||||
- Updating algorithm:
|
||||
|
||||
1) For each track currently in the library, check if the track exists
|
||||
in the filesystem and mark the track invalid if it does not.
|
||||
2) For each file in the scan directory, check if the track exists in
|
||||
|
@ -644,6 +644,31 @@ Library: (lib/library.cpp)
|
|||
This way the user will still be able to use Ocarina and scanning can
|
||||
happen while idle.
|
||||
|
||||
- Importing
|
||||
Ocarina 5.11 stores library files in ~/.ocarina/library/. Importing
|
||||
involves reading each file and adding them to the database. If the file
|
||||
describes a path already in the database then DO NOT overwrite the
|
||||
current path and instead move on to the next file. If version != 2 then
|
||||
move on to the next file.
|
||||
|
||||
File format:
|
||||
File << version << endl; /* version == 2 */
|
||||
File << path << endl;
|
||||
File << id << enabled << next_track_id << size << endl;
|
||||
File << <track list>
|
||||
|
||||
Track format:
|
||||
File << filepath << endl;
|
||||
File << title << endl;
|
||||
File << artist << endl;
|
||||
File << album << endl;
|
||||
File << comment << endl;
|
||||
File << genre << endl;
|
||||
File << lenstr << endl;
|
||||
File << id << year << track << count;
|
||||
File << last_day << last_month << last_year;
|
||||
File << length << bitrate << sample << channels << banned << endl;
|
||||
|
||||
- Testing:
|
||||
The script tests/library/gen_library.sh will create a sample library
|
||||
in the /tmp/ directory for testing purposes. All the track files are
|
||||
|
@ -677,6 +702,10 @@ Library: (lib/library.cpp)
|
|||
Return the library path with index id. Throw -EEXIST if there
|
||||
is no such path.
|
||||
|
||||
void library :: import();
|
||||
Call this function to import an Ocarina 5.11 style library,
|
||||
following the "Importing" section above.
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
void library :: print_db(DB_Type);
|
||||
Print the database corresponding to DB_Type
|
||||
|
@ -717,6 +746,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
list<sort_t> sort_order;
|
||||
unsigned int cur;
|
||||
unsigned int flags;
|
||||
unsigned int length;
|
||||
public:
|
||||
Playqueue(flags);
|
||||
void write(File &);
|
||||
|
@ -725,6 +755,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
void set_flag(playqueue_flags);
|
||||
void unset_flag(playqueue_flags);
|
||||
const unsigned int get_flags();
|
||||
string get_length();
|
||||
|
||||
unsigned int add(track_id);
|
||||
unsigned int add_front(track_id);
|
||||
|
@ -751,10 +782,12 @@ Playqueue: (lib/playqueue.cpp)
|
|||
unsigned int Playqueue :: add_front(unsigned int track_id);
|
||||
Add a new track to the tracks vector and return the index. If
|
||||
add_front is called, the track will be added to the front of
|
||||
the playqueue (index = 0);
|
||||
the playqueue (index = 0).
|
||||
length += track.length.
|
||||
|
||||
void Playqueue :: del(unsigned int playqueue_id);
|
||||
Erase tracks[playqueue_id] from the tracks vector.
|
||||
length -= track.length.
|
||||
|
||||
void Playqueue :: set_flag(playqueue_flags flag);
|
||||
void Playqueue :: unset_flag(playqueue_flags flag);
|
||||
|
@ -763,6 +796,10 @@ Playqueue: (lib/playqueue.cpp)
|
|||
const unsigned int Playqueue :: get_flags();
|
||||
Return the currently enabled flags.
|
||||
|
||||
song Playqueue :: get_length();
|
||||
Convert the length variable into a string and return the result
|
||||
to the caller.
|
||||
|
||||
unsigned int Playqueue :: size();
|
||||
Return tracks.size();
|
||||
|
||||
|
@ -796,6 +833,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
track = tracks[cur];
|
||||
|
||||
if (!(flags & PL_REPEAT)):
|
||||
length -= track.length;
|
||||
tracks.erase(cur);
|
||||
return track;
|
||||
|
||||
|
@ -848,11 +886,11 @@ Deck: (lib/deck.cpp)
|
|||
If there are no playable IDs, throw -1.
|
||||
|
||||
void deck :: reset();
|
||||
This function only exists if CONFIG_DEBUG is enabled. Erase
|
||||
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_DEBUG is enabled. Print
|
||||
This function only exists if CONFIG_TEST is enabled. Print
|
||||
out helpful stats about the current state of the playqueue deck.
|
||||
|
||||
|
||||
|
|
|
@ -109,12 +109,12 @@ Database: (lib/database.cpp)
|
|||
Clear the database contents in-memory, but do NOT write
|
||||
to disk.
|
||||
|
||||
void Database :: print()
|
||||
void Database :: print();
|
||||
This function exists only If CONFIG_TEST is enabled.
|
||||
Following a similar format for writing to disk, print the
|
||||
database to the console in a human-readable format.
|
||||
|
||||
void Database :: print_keys()
|
||||
void Database :: print_keys();
|
||||
This function exists only if CONFIG_TEST is enabled.
|
||||
Print out the collected primary keys in the database.
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ Deck: (lib/deck.cpp)
|
|||
If there are no playable IDs, throw -1.
|
||||
|
||||
void deck :: reset();
|
||||
This function only exists if CONFIG_DEBUG is enabled. Erase
|
||||
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_DEBUG is enabled. Print
|
||||
This function only exists if CONFIG_TEST is enabled. Print
|
||||
out helpful stats about the current state of the playqueue deck.
|
||||
|
|
|
@ -77,6 +77,7 @@ On-disk files: (lib/file.cpp)
|
|||
XDG_{CONFIG|DATA}_HOME/ocarina-test/filepath
|
||||
$HOME/.ocarina/
|
||||
$HOME/.ocarina-debug/
|
||||
$HOME/.ocarina-test/
|
||||
|
||||
If filepath is an empty string, set the file hint to
|
||||
FILE_TYPE_INVALID and do not set the filepath field.
|
||||
|
|
|
@ -53,5 +53,5 @@ Filter: (lib/filter.cpp)
|
|||
Print cache hit and size information.
|
||||
|
||||
void filter :: get_index();
|
||||
This function only exists if CONFIG_TEST is enabled.
|
||||
Return the index storing all the filter data.
|
||||
(Only available if -DCONFIG_TEST is set)
|
||||
|
|
|
@ -56,7 +56,7 @@ Idle queue: (lib/idle.cpp)
|
|||
static inline void idle :: schedule(void (*)(T &), T);
|
||||
Create a new IdleTask to run the function later.
|
||||
|
||||
bool idle :: run_task()
|
||||
bool idle :: run_task();
|
||||
If there are tasks on the queue:
|
||||
run the next task
|
||||
scheduled++
|
||||
|
@ -67,7 +67,7 @@ Idle queue: (lib/idle.cpp)
|
|||
scheduled = 0
|
||||
return false
|
||||
|
||||
float idle :: get_progress()
|
||||
float idle :: get_progress();
|
||||
Return (serviced / queued) to the caller. If there are no
|
||||
tasks, return 1.0 to indicate that the queue is finished (and
|
||||
to avoid a divide-by-zero error).
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
track.db
|
||||
|
||||
== Depends ==
|
||||
idle database groups filter
|
||||
idle database playlist filter
|
||||
|
||||
Library: (lib/library.cpp)
|
||||
The library manages databases containing track information added by the
|
||||
|
@ -117,7 +117,6 @@ Library: (lib/library.cpp)
|
|||
Database<library :: Track> track_db(track.db);
|
||||
|
||||
- Updating algorithm:
|
||||
|
||||
1) For each track currently in the library, check if the track exists
|
||||
in the filesystem and mark the track invalid if it does not.
|
||||
2) For each file in the scan directory, check if the track exists in
|
||||
|
@ -133,6 +132,31 @@ Library: (lib/library.cpp)
|
|||
This way the user will still be able to use Ocarina and scanning can
|
||||
happen while idle.
|
||||
|
||||
- Importing
|
||||
Ocarina 5.11 stores library files in ~/.ocarina/library/. Importing
|
||||
involves reading each file and adding them to the database. If the file
|
||||
describes a path already in the database then DO NOT overwrite the
|
||||
current path and instead move on to the next file. If version != 2 then
|
||||
move on to the next file.
|
||||
|
||||
File format:
|
||||
File << version << endl; /* version == 2 */
|
||||
File << path << endl;
|
||||
File << id << enabled << next_track_id << size << endl;
|
||||
File << <track list>
|
||||
|
||||
Track format:
|
||||
File << filepath << endl;
|
||||
File << title << endl;
|
||||
File << artist << endl;
|
||||
File << album << endl;
|
||||
File << comment << endl;
|
||||
File << genre << endl;
|
||||
File << lenstr << endl;
|
||||
File << id << year << track << count;
|
||||
File << last_day << last_month << last_year;
|
||||
File << length << bitrate << sample << channels << banned << endl;
|
||||
|
||||
- Testing:
|
||||
The script tests/library/gen_library.sh will create a sample library
|
||||
in the /tmp/ directory for testing purposes. All the track files are
|
||||
|
@ -166,6 +190,10 @@ Library: (lib/library.cpp)
|
|||
Return the library path with index id. Throw -EEXIST if there
|
||||
is no such path.
|
||||
|
||||
void library :: import();
|
||||
Call this function to import an Ocarina 5.11 style library,
|
||||
following the "Importing" section above.
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
void library :: print_db(DB_Type);
|
||||
Print the database corresponding to DB_Type
|
||||
|
|
|
@ -29,14 +29,14 @@ Playlists: (lib/playlist.cpp)
|
|||
un-banned.
|
||||
|
||||
- API
|
||||
void playlist :: add(name, track_id)
|
||||
void playlist :: add(name, track_id);
|
||||
playlist_idx.insert(name, track_id);
|
||||
|
||||
void playlist :: del(name, track_id)
|
||||
void playlist :: del(name, track_id);
|
||||
playlist_idx.delete(name, track_id)
|
||||
|
||||
void void playlist :: list(list<string> &);
|
||||
return playlist_idx.keys();
|
||||
|
||||
void playlist :: get_tracks(name):
|
||||
void playlist :: get_tracks(name);
|
||||
return playlist_idx[name]
|
||||
|
|
|
@ -37,6 +37,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
list<sort_t> sort_order;
|
||||
unsigned int cur;
|
||||
unsigned int flags;
|
||||
unsigned int length;
|
||||
public:
|
||||
Playqueue(flags);
|
||||
void write(File &);
|
||||
|
@ -45,6 +46,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
void set_flag(playqueue_flags);
|
||||
void unset_flag(playqueue_flags);
|
||||
const unsigned int get_flags();
|
||||
string get_length();
|
||||
|
||||
unsigned int add(track_id);
|
||||
unsigned int add_front(track_id);
|
||||
|
@ -71,10 +73,12 @@ Playqueue: (lib/playqueue.cpp)
|
|||
unsigned int Playqueue :: add_front(unsigned int track_id);
|
||||
Add a new track to the tracks vector and return the index. If
|
||||
add_front is called, the track will be added to the front of
|
||||
the playqueue (index = 0);
|
||||
the playqueue (index = 0).
|
||||
length += track.length.
|
||||
|
||||
void Playqueue :: del(unsigned int playqueue_id);
|
||||
Erase tracks[playqueue_id] from the tracks vector.
|
||||
length -= track.length.
|
||||
|
||||
void Playqueue :: set_flag(playqueue_flags flag);
|
||||
void Playqueue :: unset_flag(playqueue_flags flag);
|
||||
|
@ -83,6 +87,10 @@ Playqueue: (lib/playqueue.cpp)
|
|||
const unsigned int Playqueue :: get_flags();
|
||||
Return the currently enabled flags.
|
||||
|
||||
song Playqueue :: get_length();
|
||||
Convert the length variable into a string and return the result
|
||||
to the caller.
|
||||
|
||||
unsigned int Playqueue :: size();
|
||||
Return tracks.size();
|
||||
|
||||
|
@ -116,6 +124,7 @@ Playqueue: (lib/playqueue.cpp)
|
|||
track = tracks[cur];
|
||||
|
||||
if (!(flags & PL_REPEAT)):
|
||||
length -= track.length;
|
||||
tracks.erase(cur);
|
||||
return track;
|
||||
|
||||
|
|
Loading…
Reference in New Issue