driver: Add doxygen documentation
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
9a5549a264
commit
3d00a83b6a
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/**
|
||||||
|
* @file
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/driver.h>
|
#include <core/driver.h>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/**
|
||||||
|
* @file
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#ifndef OCARINA_CORE_DRIVER_H
|
#ifndef OCARINA_CORE_DRIVER_H
|
||||||
|
@ -6,26 +7,87 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/** Use to convert nanoseconds to seconds */
|
||||||
static const unsigned long O_SECOND = 1000000000;
|
static const unsigned long O_SECOND = 1000000000;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for different audio drivers.
|
||||||
|
*/
|
||||||
class Driver {
|
class Driver {
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* End-of-stream callback function.
|
||||||
|
*/
|
||||||
void (*on_eos)();
|
void (*on_eos)();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error handling callback function.
|
||||||
|
*/
|
||||||
void (*on_error)();
|
void (*on_error)();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Default Driver constructor.
|
||||||
|
*/
|
||||||
Driver();
|
Driver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Driver destructor.
|
||||||
|
*/
|
||||||
~Driver();
|
~Driver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a driver
|
||||||
|
* @param argc Argc passed to the application's main() function.
|
||||||
|
* @param argv Argv passed to the applicaiton's main() function.
|
||||||
|
* @param eos_cb End-of-stream callback function.
|
||||||
|
* @param error_cb Callback function used when the audio library encounters an error.
|
||||||
|
*/
|
||||||
virtual void init(int *, char ***, void (*)(), void (*)()) = 0;
|
virtual void init(int *, char ***, void (*)(), void (*)()) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an audio file for playback.
|
||||||
|
* @param file Filepath of the track to load.
|
||||||
|
*/
|
||||||
virtual void load(const std::string &) = 0;
|
virtual void load(const std::string &) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to begin playback on the currently loaded track.
|
||||||
|
* @return True if playback state was changed successfully, false otherwise.
|
||||||
|
*/
|
||||||
virtual bool play() = 0;
|
virtual bool play() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to pause playback on the currently loaded track.
|
||||||
|
* @return True if playback state was changed successfully, false otherwise.
|
||||||
|
*/
|
||||||
virtual bool pause() = 0;
|
virtual bool pause() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to check if the audio library is currently playing a track.
|
||||||
|
* @return True if audio library is playing, false otherwise.
|
||||||
|
*/
|
||||||
virtual bool is_playing() = 0;
|
virtual bool is_playing() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to a specific position in the current track.
|
||||||
|
* @param offset Position from the beginning of the track where we will seek to, in nanoseconds.
|
||||||
|
*/
|
||||||
virtual void seek_to(long) = 0;
|
virtual void seek_to(long) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current position of the playback.
|
||||||
|
* @return The current playback position, in nanoseconds.
|
||||||
|
*/
|
||||||
virtual long position() = 0;
|
virtual long position() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the duration of the currently loaded track.
|
||||||
|
* @return The duration of the current track, in nanoseconds.
|
||||||
|
*/
|
||||||
virtual long duration() = 0;
|
virtual long duration() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +121,9 @@ public:
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Driver for the GStreamer audio library.
|
||||||
|
*/
|
||||||
class GSTDriver : public Driver
|
class GSTDriver : public Driver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -67,27 +132,88 @@ private:
|
||||||
bool change_state(GstState state);
|
bool change_state(GstState state);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* GStreamer audio driver constructor.
|
||||||
|
*/
|
||||||
GSTDriver();
|
GSTDriver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GStreamer audio driver destructor.
|
||||||
|
*/
|
||||||
~GSTDriver();
|
~GSTDriver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to initialize the GStreamer audio driver.
|
||||||
|
* @param argc Argc passed to the application's main() function.
|
||||||
|
* @param argv Argv passed to the applicaiton's main() function.
|
||||||
|
* @param eos_cb End-of-stream callback function.
|
||||||
|
* @param error_cb Callback function used when the audio library encounters an error.
|
||||||
|
*/
|
||||||
void init(int *, char ***, void (*)(), void (*)());
|
void init(int *, char ***, void (*)(), void (*)());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a track into the gstreamer pipeline.
|
||||||
|
* @param filepath The file to be loaded.
|
||||||
|
*/
|
||||||
void load(const std::string &);
|
void load(const std::string &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin playback on the GStreamer pipeline.
|
||||||
|
* @return True if the state change was successful.
|
||||||
|
*/
|
||||||
bool play();
|
bool play();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause the GStreamer pipeline.
|
||||||
|
* @return True if the state change was successful.
|
||||||
|
*/
|
||||||
bool pause();
|
bool pause();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the GStreamer pipeline is playing.
|
||||||
|
* @return True if the pipeline is playing.
|
||||||
|
*/
|
||||||
bool is_playing();
|
bool is_playing();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to a specific position in the pipeline.
|
||||||
|
* @param offset Offset from the beginning of the pipeline, in nanoseconds.
|
||||||
|
*/
|
||||||
void seek_to(long);
|
void seek_to(long);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the current playback position of the pipeline.
|
||||||
|
* @return The current position of the pipeline, in nanoseconds.
|
||||||
|
*/
|
||||||
long position();
|
long position();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the duration of the pipeline.
|
||||||
|
* @return The duration of the pipeline, in nanoseconds.
|
||||||
|
*/
|
||||||
long duration();
|
long duration();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to handle messages from the GStreamer bus.
|
||||||
|
* @param message The message to be handled.
|
||||||
|
*/
|
||||||
void on_message(GstMessage *);
|
void on_message(GstMessage *);
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_TEST */
|
#endif /* CONFIG_TEST */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace for audio driver access.
|
||||||
|
*/
|
||||||
namespace driver
|
namespace driver
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access an audio driver.
|
||||||
|
* @return The current driver used by the application.
|
||||||
|
*/
|
||||||
Driver *get_driver();
|
Driver *get_driver();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue