design: Update design.txt
This matches the current state of the backend library and does not have any tweaks for the GUI. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
2c243194d7
commit
e1d527f077
103
design.txt
103
design.txt
|
@ -667,15 +667,16 @@ Playlist: (lib/playlist.cpp)
|
|||
unsigned int flags;
|
||||
public:
|
||||
Playlist(flags);
|
||||
unsigned int add(track_id);
|
||||
void del(playlist_id);
|
||||
void write(File &);
|
||||
void read(File &);
|
||||
|
||||
void set_flag(playlist_flags);
|
||||
void unset_flag(playlist_flags);
|
||||
const unsigned int get_flags();
|
||||
unsigned int size();
|
||||
|
||||
void write(File &);
|
||||
void read(File &);
|
||||
unsigned int add(track_id);
|
||||
void del(playlist_id);
|
||||
unsigned int size();
|
||||
|
||||
void sort();
|
||||
unsigned int next();
|
||||
|
@ -711,6 +712,8 @@ Playlist: (lib/playlist.cpp)
|
|||
Sort a playlist in Artist -> Year -> Track number order.
|
||||
|
||||
unsigned int next();
|
||||
Return the next track_id to play.
|
||||
|
||||
if (flags & PL_RANDOM):
|
||||
cur += rand() % tracks.size();
|
||||
else:
|
||||
|
@ -732,26 +735,30 @@ Deck: (lib/deck.cpp)
|
|||
|
||||
- Deck:
|
||||
list<Playlist> deck;
|
||||
unsigned int current_track;
|
||||
|
||||
File << current_track << deck.size() << endl;
|
||||
File << deck.size() << endl;
|
||||
File << deck[0] << endl;
|
||||
File << deck[N] << endl;
|
||||
|
||||
- API
|
||||
void deck :: init();
|
||||
Read in the playlist file.
|
||||
void deck :: read(File &);
|
||||
void deck :: write(File &);
|
||||
Read or write the playlist file. This will be called
|
||||
from the audio layer to store state.
|
||||
|
||||
unsigned int deck :: new();
|
||||
Adds a new playlist to the end of the deck and returns its id.
|
||||
The id is only valid until the deck is changed in some way.
|
||||
Playlist *deck :: create();
|
||||
Adds a new playlist to the end of the deck and returns a
|
||||
pointer to it.
|
||||
|
||||
void deck :: rm(N);
|
||||
void deck :: remove(N);
|
||||
Remove playlist N from the deck.
|
||||
|
||||
Playlist *deck :: get(N);
|
||||
Return playlist N from the deck.
|
||||
|
||||
void deck :: move(M, N);
|
||||
Move playlist at index M to index N.
|
||||
|
||||
unsigned int deck :: next();
|
||||
Iterate through the deck until you find a playlist with the
|
||||
flag PL_ENABLED set. Call next() on this playlist and return
|
||||
|
@ -760,6 +767,16 @@ Deck: (lib/deck.cpp)
|
|||
If the playlist is empty after calling next(), remove it from
|
||||
the deck.
|
||||
|
||||
If there are no playable IDs, throw -1.
|
||||
|
||||
void deck :: reset();
|
||||
This function only exists if CONFIG_DEBUG is enabled. Erase
|
||||
all the playlist information and reset the deck list.
|
||||
|
||||
void deck :: print_info();
|
||||
This function only exists if CONFIG_DEBUG is enabled. Print
|
||||
out helpful stats about the current state of the playlist deck.
|
||||
|
||||
|
||||
|
||||
Audio: (lib/audio.cpp)
|
||||
|
@ -768,11 +785,12 @@ Audio: (lib/audio.cpp)
|
|||
namespace that will be easier to work with than using raw gstreamer
|
||||
functions.
|
||||
|
||||
The audio layer will also control the "pause after N tracks" feature
|
||||
so songs can be loaded without neeting to pass in a "begin playback"
|
||||
flag every time. The remaining tracks counter will only be decremented
|
||||
when a song finishes through the end-of-stream message passed by the
|
||||
gst pipeline.
|
||||
The audio layer is meant to be an interface used by the front end to
|
||||
control most features of the backend library. This means implementing
|
||||
next track, previous track, and so on here.
|
||||
|
||||
Gstreamer options passed to audio :: init() can be found by running
|
||||
`gst-inspect-1.0 --help-gst` on the command line.
|
||||
|
||||
- Internal:
|
||||
Set up a message bus to look for end-of-stream and error messages so
|
||||
|
@ -783,27 +801,36 @@ Audio: (lib/audio.cpp)
|
|||
- API:
|
||||
void audio :: init(argc, argv)
|
||||
Initialize the gstreamer layer and reload the track that was
|
||||
last loaded before shutdown. Please only pass --gst-* options
|
||||
for argv.
|
||||
last loaded before shutdown. Gstreamer is supposed to remove
|
||||
options from the argv array as they are processed, so pass
|
||||
pointers to argc and argv to this function.
|
||||
|
||||
void audio :: play()
|
||||
Begin or resume playback.
|
||||
void audio :: quit()
|
||||
Clean up memory allocated by gstreamer.
|
||||
|
||||
void audio :: pause()
|
||||
Pause playback.
|
||||
bool audio :: play()
|
||||
bool audio :: pause()
|
||||
Change the gstreamer state to either GST_STATE_PLAYING or
|
||||
GST_STATE_PAUSED. Return true on success and false otherwise.
|
||||
|
||||
void audio :: seek_to(int)
|
||||
Seek to a position X seconds into the track
|
||||
bool audio :: seek_to(long)
|
||||
Seek to a position X nanoseconds into the track. Return true
|
||||
if track is loaded and the seek isn't out of bounds. False
|
||||
otherwise.
|
||||
|
||||
Seconds can be converted to nanoseconds by multiplying with
|
||||
GST_SECOND.
|
||||
|
||||
void audio :: stop()
|
||||
pause()
|
||||
seek_to(0)
|
||||
|
||||
void audio :: next()
|
||||
Call the playlist :: next() function to get the next trackid,
|
||||
bool audio :: next()
|
||||
Call the deck :: next() function to get the next trackid,
|
||||
and load that file into the gstreamer pipeline. Do not change
|
||||
the state of the pipeline (if nothing is playing yet, don't
|
||||
call play()).
|
||||
call play()). Return true if a track has been loaded into the
|
||||
pipeline, false otherwise.
|
||||
|
||||
void audio :: previous()
|
||||
Call the playlist :: previous() function to iterate backwards
|
||||
|
@ -819,8 +846,18 @@ Audio: (lib/audio.cpp)
|
|||
unsigned int audio :: duration()
|
||||
Return the duration of the current song in seconds.
|
||||
|
||||
void audio :: pause_after(unsigned int)
|
||||
Pause after N tracks, pass a negative number to disable.
|
||||
void audio :: pause_after(bool enabled, unsigned int N)
|
||||
Pause after N tracks. The first parameter is a bool
|
||||
representing if this feature is enabled or not (true == enabled,
|
||||
false == disabled).
|
||||
|
||||
The count will only be decremented when an end-of-stream message
|
||||
is received by the gstreamer pipeline, and not when calling
|
||||
next().
|
||||
|
||||
bool audio :: pause_enabled()
|
||||
Return true if pausing is enabled, and false if pausing is
|
||||
disabled.
|
||||
|
||||
unsigned int audio :: pause_count()
|
||||
Return the number of tracks that will be played before
|
||||
|
@ -919,7 +956,9 @@ Future work:
|
|||
|
||||
- Extra testing ideas: (6.1)
|
||||
- Run tests through valgrind to help find memory leaks
|
||||
- Combine earlier tests into a single file
|
||||
- Some way to enable / disable tests during development
|
||||
- Run tests based on dependencies
|
||||
- Fix tests that will only work on my computer
|
||||
|
||||
- Exceptions: (6.1)
|
||||
- Don't return error codes, throw exceptions like C++ is
|
||||
|
|
|
@ -76,7 +76,9 @@ Future work:
|
|||
|
||||
- Extra testing ideas: (6.1)
|
||||
- Run tests through valgrind to help find memory leaks
|
||||
- Combine earlier tests into a single file
|
||||
- Some way to enable / disable tests during development
|
||||
- Run tests based on dependencies
|
||||
- Fix tests that will only work on my computer
|
||||
|
||||
- Exceptions: (6.1)
|
||||
- Don't return error codes, throw exceptions like C++ is
|
||||
|
|
Loading…
Reference in New Issue