2014-09-12 16:08:58 -04:00
|
|
|
/**
|
2013-12-24 20:17:44 -05:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-21 09:37:47 -04:00
|
|
|
#ifndef OCARINA_CORE_AUDIO_H
|
|
|
|
#define OCARINA_CORE_AUDIO_H
|
2013-12-24 20:17:44 -05:00
|
|
|
|
2015-11-12 10:42:21 -05:00
|
|
|
extern "C" {
|
2014-12-02 08:16:22 -05:00
|
|
|
#include <core/tags/track.h>
|
2015-11-12 10:42:21 -05:00
|
|
|
}
|
2015-12-15 08:16:06 -05:00
|
|
|
#include <gst/gst.h>
|
2014-01-22 22:31:42 -05:00
|
|
|
#include <string>
|
2015-03-05 11:00:33 -05:00
|
|
|
#include <stdint.h>
|
2014-01-22 22:31:42 -05:00
|
|
|
|
2014-12-20 15:47:10 -05:00
|
|
|
|
2015-12-15 10:23:15 -05:00
|
|
|
struct audio_ops {
|
|
|
|
/* Called when a track is loaded. */
|
|
|
|
void (*on_load)(struct track *, GstState);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-09-12 16:08:58 -04:00
|
|
|
/**
|
2014-12-20 15:47:10 -05:00
|
|
|
* The audio driver class gives us an interface for using multiple
|
|
|
|
* audio frameworks for audio playback.
|
2014-09-12 16:08:58 -04:00
|
|
|
*/
|
2014-12-20 15:47:10 -05:00
|
|
|
class AudioDriver {
|
|
|
|
public:
|
|
|
|
AudioDriver(); /**< Default AudioDriver constructor. */
|
|
|
|
virtual ~AudioDriver(); /**< AudioDriver destructor. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to handle reaching the end-of-stream.
|
|
|
|
*/
|
|
|
|
void eos();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespace for higher-level audio controls.
|
|
|
|
*/
|
|
|
|
namespace audio
|
|
|
|
{
|
2013-12-24 20:17:44 -05:00
|
|
|
|
2014-12-20 15:47:10 -05:00
|
|
|
void next(); /**< Find and load the next track that should be played. */
|
|
|
|
void prev(); /**< Call the deck :: previous() function and load the result. */
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure the automatic pausing feature.
|
|
|
|
*
|
|
|
|
* @param enabled Set to true to enable pausing, false to disable.
|
|
|
|
* @param n Number of tracks to play before pausing.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
void pause_after(bool, unsigned int);
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call to find the current automatic pausing state.
|
|
|
|
*
|
|
|
|
* @return True if automatic pausing is enabled, false otherwise.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
bool pause_enabled();
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call to find the number of tracks remaining before pausing.
|
|
|
|
*
|
|
|
|
* @return The number of tracks before pausing.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
unsigned int pause_count();
|
2014-12-19 14:53:42 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to access an audio driver.
|
|
|
|
*
|
|
|
|
* @return The current driver used by the application.
|
|
|
|
*/
|
2014-12-20 15:47:10 -05:00
|
|
|
AudioDriver *get_driver();
|
2013-12-24 20:17:44 -05:00
|
|
|
};
|
|
|
|
|
2015-12-15 08:16:06 -05:00
|
|
|
|
|
|
|
/* Called to initialize the audio manager. */
|
2015-12-15 10:23:15 -05:00
|
|
|
void audio_init(int *, char ***, struct audio_ops *);
|
2015-12-15 08:16:06 -05:00
|
|
|
|
2015-12-15 10:46:48 -05:00
|
|
|
/* Called to deinitialize the audio manager. */
|
|
|
|
void audio_deinit();
|
|
|
|
|
2015-12-15 08:16:06 -05:00
|
|
|
|
2015-12-15 10:23:15 -05:00
|
|
|
/* Called to load a track for playback. */
|
|
|
|
bool audio_load(struct track *);
|
|
|
|
|
2015-12-16 08:26:49 -05:00
|
|
|
/* Called to get the current track. */
|
|
|
|
struct track *audio_cur_track();
|
|
|
|
|
2015-12-16 09:18:01 -05:00
|
|
|
/* Called to get the current playback state. */
|
|
|
|
GstState audio_cur_state();
|
|
|
|
|
2015-12-16 08:26:49 -05:00
|
|
|
|
2015-12-15 14:17:17 -05:00
|
|
|
/* Called to begin playback. */
|
|
|
|
bool audio_play();
|
|
|
|
|
2015-12-15 14:34:13 -05:00
|
|
|
/* Called to pause playback. */
|
|
|
|
bool audio_pause();
|
|
|
|
|
2015-12-16 08:16:46 -05:00
|
|
|
/* Called to stop playback. */
|
|
|
|
bool audio_stop();
|
|
|
|
|
2015-12-15 15:50:02 -05:00
|
|
|
/* Called to seek playback to a specific offset, in nanoseconds. */
|
|
|
|
bool audio_seek(gint64);
|
|
|
|
|
2015-12-15 16:42:49 -05:00
|
|
|
/* Called to find the current playback position, in nanoseconds. */
|
|
|
|
gint64 audio_position();
|
|
|
|
|
2015-12-16 08:00:19 -05:00
|
|
|
/* Called to find the duration of the current track. */
|
|
|
|
gint64 audio_duration();
|
|
|
|
|
2015-12-15 08:16:06 -05:00
|
|
|
GstElement *audio_get_player();
|
2014-06-21 09:37:47 -04:00
|
|
|
#endif /* OCARINA_CORE_AUDIO_H */
|