audio: Move Driver into audio.h
I also rename from Driver -> AudioDriver. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
acac350879
commit
92d264d4ac
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/deck.h>
|
||||
#include <core/driver.h>
|
||||
#include <core/library.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
@ -16,23 +16,23 @@ static unsigned int _pause_count = 0;
|
|||
static Track *cur_track = NULL;
|
||||
static File f_cur_track("cur_track", 0);
|
||||
|
||||
static Driver *cur_driver = NULL;
|
||||
static AudioDriver *cur_driver = NULL;
|
||||
|
||||
static void _load_track(Track *, bool);
|
||||
static bool continue_playback();
|
||||
|
||||
|
||||
Driver :: Driver()
|
||||
AudioDriver :: AudioDriver()
|
||||
{
|
||||
cur_driver = this;
|
||||
}
|
||||
|
||||
Driver :: ~Driver()
|
||||
AudioDriver :: ~AudioDriver()
|
||||
{
|
||||
cur_driver = NULL;
|
||||
}
|
||||
|
||||
void Driver :: eos()
|
||||
void AudioDriver :: eos()
|
||||
{
|
||||
if (cur_track) {
|
||||
cur_track->played();
|
||||
|
@ -191,7 +191,7 @@ unsigned int audio :: pause_count()
|
|||
return _pause_count;
|
||||
}
|
||||
|
||||
Driver *audio :: get_driver()
|
||||
AudioDriver *audio :: get_driver()
|
||||
{
|
||||
return cur_driver;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include <lib/lib.h>
|
||||
#include <core/audio.h>
|
||||
#include <core/driver.h>
|
||||
#include <gui/ocarina.h>
|
||||
|
||||
static Gtk::Label *o_position;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* what options are supported.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/driver.h>
|
||||
#include <gui/ocarina.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
@ -30,7 +29,7 @@ static bool gst_change_state(GstState state)
|
|||
}
|
||||
|
||||
|
||||
class GSTDriver : public Driver
|
||||
class GSTDriver : public AudioDriver
|
||||
{
|
||||
public:
|
||||
void load(Track *track)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/deck.h>
|
||||
#include <core/driver.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/print.h>
|
||||
#include <lib/colmgr.h>
|
||||
|
|
|
@ -5,23 +5,89 @@
|
|||
#ifndef OCARINA_CORE_AUDIO_H
|
||||
#define OCARINA_CORE_AUDIO_H
|
||||
|
||||
#include <core/driver.h>
|
||||
#include <core/tags/track.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
/** Use to convert nanoseconds to seconds */
|
||||
static const unsigned long O_SECOND = 1000000000;
|
||||
|
||||
|
||||
/**
|
||||
* The audio driver class gives us an interface for using multiple
|
||||
* audio frameworks for audio playback.
|
||||
*/
|
||||
class AudioDriver {
|
||||
protected:
|
||||
void (*on_error) (); /**< Error handling callback function. */
|
||||
|
||||
public:
|
||||
AudioDriver(); /**< Default AudioDriver constructor. */
|
||||
virtual ~AudioDriver(); /**< AudioDriver destructor. */
|
||||
|
||||
|
||||
/**
|
||||
* Loads an audio file for playback.
|
||||
*
|
||||
* @param track The Track to load.
|
||||
*/
|
||||
virtual void load(Track *track) = 0;
|
||||
|
||||
/**
|
||||
* Called to begin playback on the currently loaded track.
|
||||
*/
|
||||
virtual void play() = 0;
|
||||
|
||||
/**
|
||||
* Called to pause playback on the currently loaded track.
|
||||
*/
|
||||
virtual void 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;
|
||||
|
||||
|
||||
/**
|
||||
* 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 offset) = 0;
|
||||
|
||||
/**
|
||||
* Return the current position of the playback.
|
||||
*
|
||||
* @return The current playback position, in nanoseconds.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Called to handle reaching the end-of-stream.
|
||||
*/
|
||||
void eos();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Namespace for higher-level audio controls.
|
||||
*/
|
||||
namespace audio
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes the audio layer and currently configured audio driver.
|
||||
*/
|
||||
void init();
|
||||
|
||||
void play(); /** Begin playback. */
|
||||
void pause(); /** Pause playback. */
|
||||
void init(); /**< Initializes the audio layer. */
|
||||
void play(); /**< Begin playback. */
|
||||
void pause(); /**< Pause playback. */
|
||||
|
||||
/**
|
||||
* Seek to a specific point in the track.
|
||||
|
@ -31,7 +97,7 @@ namespace audio
|
|||
void seek_to(long);
|
||||
|
||||
/**
|
||||
* Stop playback (equivalent to pause(); seek_to(0);).
|
||||
* Stop playback and seek to the beginning of the track.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
|
@ -50,8 +116,8 @@ namespace audio
|
|||
*/
|
||||
std::string position_str();
|
||||
|
||||
void next(); /** Find and load the next track that should be played. */
|
||||
void prev(); /** Call the deck :: previous() function and load the result. */
|
||||
void next(); /**< Find and load the next track that should be played. */
|
||||
void prev(); /**< Call the deck :: previous() function and load the result. */
|
||||
|
||||
/**
|
||||
* Load a specific track for playback.
|
||||
|
@ -92,7 +158,7 @@ namespace audio
|
|||
*
|
||||
* @return The current driver used by the application.
|
||||
*/
|
||||
Driver *get_driver();
|
||||
AudioDriver *get_driver();
|
||||
};
|
||||
|
||||
#endif /* OCARINA_CORE_AUDIO_H */
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* @file
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_CORE_DRIVER_H
|
||||
#define OCARINA_CORE_DRIVER_H
|
||||
|
||||
#include <core/tags/track.h>
|
||||
#include <string>
|
||||
|
||||
/** Use to convert nanoseconds to seconds */
|
||||
static const unsigned long O_SECOND = 1000000000;
|
||||
|
||||
|
||||
/**
|
||||
* The audio driver class gives us an interface for using multiple
|
||||
* audio frameworks for audio playback.
|
||||
*/
|
||||
class Driver {
|
||||
protected:
|
||||
void (*on_error) (); /**< Error handling callback function. */
|
||||
|
||||
public:
|
||||
Driver(); /**< Default Driver constructor. */
|
||||
virtual ~Driver(); /**< Driver destructor. */
|
||||
|
||||
|
||||
/**
|
||||
* Loads an audio file for playback.
|
||||
*
|
||||
* @param track The Track to load.
|
||||
*/
|
||||
virtual void load(Track *track) = 0;
|
||||
|
||||
/**
|
||||
* Called to begin playback on the currently loaded track.
|
||||
*/
|
||||
virtual void play() = 0;
|
||||
|
||||
/**
|
||||
* Called to pause playback on the currently loaded track.
|
||||
*/
|
||||
virtual void 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;
|
||||
|
||||
|
||||
/**
|
||||
* 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 offset) = 0;
|
||||
|
||||
/**
|
||||
* Return the current position of the playback.
|
||||
*
|
||||
* @return The current playback position, in nanoseconds.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Called to handle reaching the end-of-stream.
|
||||
*/
|
||||
void eos();
|
||||
};
|
||||
|
||||
#endif /* OCARINA_CORE_DRIVER_H */
|
|
@ -2,7 +2,6 @@
|
|||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/driver.h>
|
||||
#include <core/library.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include <tests/test.h>
|
||||
|
@ -10,7 +9,7 @@
|
|||
Track *TRACK_NULL = NULL;
|
||||
|
||||
|
||||
class TestDriver : public Driver
|
||||
class TestDriver : public AudioDriver
|
||||
{
|
||||
public:
|
||||
bool playing;
|
||||
|
|
Loading…
Reference in New Issue
Block a user