83 lines
2.7 KiB
Plaintext
83 lines
2.7 KiB
Plaintext
== Files ==
|
|
ocarina/include/
|
|
audio.h
|
|
ocarina/lib/
|
|
audio.cpp
|
|
|
|
== Depends ==
|
|
deck library
|
|
|
|
Audio: (lib/audio.cpp)
|
|
This file will introduce an "audio" namespace containing all of the
|
|
functions interacting with gstreamer. This will create a wrapper
|
|
namespace that will be easier to work with than using raw gstreamer
|
|
functions.
|
|
|
|
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
|
|
the next song can be played. This function should call the play
|
|
function after loading a track and after checking the "pause after N"
|
|
count.
|
|
|
|
- API:
|
|
void audio :: init(argc, argv)
|
|
Initialize the gstreamer layer and reload the track that was
|
|
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.
|
|
|
|
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.
|
|
|
|
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)
|
|
|
|
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()). Return true if a track has been loaded into the
|
|
pipeline, false otherwise.
|
|
|
|
void audio :: previous()
|
|
Call the playlist :: previous() function to iterate backwards
|
|
through the recently played playlist. Load the returned trackid
|
|
without changing the pipeline state.
|
|
|
|
trackid audio :: current_trackid()
|
|
Return the trackid of the currently playing song.
|
|
|
|
unsigned int audio :: position()
|
|
Return the number of seconds that the song has played.
|
|
|
|
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. The
|
|
count will only be decremented when an end-of-stream message
|
|
is received by the gstreamer pipeline.
|
|
|
|
unsigned int audio :: pause_count()
|
|
Return the number of tracks that will be played before
|
|
playback pauses. Throw -1 if the user does not want us to
|
|
pause.
|