[DEV] start rework Lib
This commit is contained in:
parent
b21b2f7413
commit
fca89ede03
@ -34,15 +34,15 @@ airtaudio::Api::~Api(void) {
|
||||
|
||||
}
|
||||
|
||||
void airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
||||
airtaudio::StreamParameters *iParams,
|
||||
airtaudio::format format,
|
||||
uint32_t sampleRate,
|
||||
uint32_t *bufferFrames,
|
||||
airtaudio::AirTAudioCallback callback,
|
||||
void *userData,
|
||||
airtaudio::StreamOptions *options,
|
||||
airtaudio::AirTAudioErrorCallback errorCallback) {
|
||||
enum airtaudio::errorType airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
||||
airtaudio::StreamParameters *iParams,
|
||||
airtaudio::format format,
|
||||
uint32_t sampleRate,
|
||||
uint32_t *bufferFrames,
|
||||
airtaudio::AirTAudioCallback callback,
|
||||
void *userData,
|
||||
airtaudio::StreamOptions *options,
|
||||
airtaudio::AirTAudioErrorCallback errorCallback) {
|
||||
if (m_stream.state != airtaudio::api::STREAM_CLOSED) {
|
||||
m_errorText = "airtaudio::Api::openStream: a stream is already open!";
|
||||
error(airtaudio::errorInvalidUse);
|
||||
@ -113,7 +113,9 @@ void airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
||||
bufferFrames,
|
||||
options);
|
||||
if (result == false) {
|
||||
if (oChannels > 0) closeStream();
|
||||
if (oChannels > 0) {
|
||||
closeStream();
|
||||
}
|
||||
error(airtaudio::errorSystemError);
|
||||
return;
|
||||
}
|
||||
@ -137,9 +139,9 @@ uint32_t airtaudio::Api::getDefaultOutputDevice(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void airtaudio::Api::closeStream(void) {
|
||||
enum airtaudio::errorType airtaudio::Api::closeStream(void) {
|
||||
// MUST be implemented in subclasses!
|
||||
return;
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
|
||||
bool airtaudio::Api::probeDeviceOpen(uint32_t /*device*/,
|
||||
|
@ -17,15 +17,20 @@ namespace airtaudio {
|
||||
* @brief Audio API specifier arguments.
|
||||
*/
|
||||
enum type {
|
||||
UNSPECIFIED, /*!< Search for a working compiled API. */
|
||||
LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
|
||||
LINUX_PULSE, /*!< The Linux PulseAudio API. */
|
||||
LINUX_OSS, /*!< The Linux Open Sound System API. */
|
||||
UNIX_JACK, /*!< The Jack Low-Latency Audio Server API. */
|
||||
MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */
|
||||
WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */
|
||||
WINDOWS_DS, /*!< The Microsoft Direct Sound API. */
|
||||
RTAUDIO_DUMMY /*!< A compilable but non-functional API. */
|
||||
UNSPECIFIED, //!< Search for a working compiled API.
|
||||
LINUX_ALSA, //!< The Advanced Linux Sound Architecture API.
|
||||
LINUX_PULSE, //!< The Linux PulseAudio API.
|
||||
LINUX_OSS, //!< The Linux Open Sound System API.
|
||||
UNIX_JACK, //!< The Jack Low-Latency Audio Server API.
|
||||
MACOSX_CORE, //!< Macintosh OS-X Core Audio API.
|
||||
WINDOWS_ASIO, //!< The Steinberg Audio Stream I/O API.
|
||||
WINDOWS_DS, //!< The Microsoft Direct Sound API.
|
||||
RTAUDIO_DUMMY, //!< A compilable but non-functional API.
|
||||
ANDROID_JAVA, //!< Android Interface.
|
||||
USER_INTERFACE_1, //!< User interface 1.
|
||||
USER_INTERFACE_2, //!< User interface 2.
|
||||
USER_INTERFACE_3, //!< User interface 3.
|
||||
USER_INTERFACE_4, //!< User interface 4.
|
||||
};
|
||||
|
||||
extern const uint32_t MAX_SAMPLE_RATES;
|
||||
@ -118,19 +123,19 @@ namespace airtaudio {
|
||||
virtual airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) = 0;
|
||||
virtual uint32_t getDefaultInputDevice(void);
|
||||
virtual uint32_t getDefaultOutputDevice(void);
|
||||
void openStream(airtaudio::StreamParameters *_outputParameters,
|
||||
airtaudio::StreamParameters *_inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t *_bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void *_userData,
|
||||
airtaudio::StreamOptions *_options,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback);
|
||||
virtual void closeStream(void);
|
||||
virtual void startStream(void) = 0;
|
||||
virtual void stopStream(void) = 0;
|
||||
virtual void abortStream(void) = 0;
|
||||
enum airtaudio::errorType openStream(airtaudio::StreamParameters *_outputParameters,
|
||||
airtaudio::StreamParameters *_inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t *_bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void *_userData,
|
||||
airtaudio::StreamOptions *_options,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback);
|
||||
virtual enum airtaudio::errorType closeStream(void);
|
||||
virtual enum airtaudio::errorType startStream(void) = 0;
|
||||
virtual enum airtaudio::errorType stopStream(void) = 0;
|
||||
virtual enum airtaudio::errorType abortStream(void) = 0;
|
||||
long getStreamLatency(void);
|
||||
uint32_t getStreamSampleRate(void);
|
||||
virtual double getStreamTime(void);
|
||||
|
@ -13,110 +13,93 @@ std::vector<airtaudio::api::type> airtaudio::Interface::getCompiledApi(void) {
|
||||
std::vector<airtaudio::api::type> apis;
|
||||
// The order here will control the order of RtAudio's API search in
|
||||
// the constructor.
|
||||
#if defined(__UNIX_JACK__)
|
||||
apis.push_back(airtaudio::api::UNIX_JACK);
|
||||
#endif
|
||||
#if defined(__LINUX_ALSA__)
|
||||
apis.push_back(airtaudio::api::LINUX_ALSA);
|
||||
#endif
|
||||
#if defined(__LINUX_PULSE__)
|
||||
apis.push_back(airtaudio::api::LINUX_PULSE);
|
||||
#endif
|
||||
#if defined(__LINUX_OSS__)
|
||||
apis.push_back(airtaudio::api::LINUX_OSS);
|
||||
#endif
|
||||
#if defined(__WINDOWS_ASIO__)
|
||||
apis.push_back(airtaudio::api::WINDOWS_ASIO);
|
||||
#endif
|
||||
#if defined(__WINDOWS_DS__)
|
||||
apis.push_back(airtaudio::api::WINDOWS_DS);
|
||||
#endif
|
||||
#if defined(__MACOSX_CORE__)
|
||||
apis.push_back(airtaudio::api::MACOSX_CORE);
|
||||
#endif
|
||||
#if defined(__AIRTAUDIO_DUMMY__)
|
||||
apis.push_back(airtaudio::api::RTAUDIO_DUMMY);
|
||||
#endif
|
||||
for (auto &it : m_apiAvaillable) {
|
||||
apis.push_back(it.first);
|
||||
}
|
||||
return apis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void airtaudio::Interface::openRtApi(airtaudio::api::type _api) {
|
||||
if (m_rtapi != NULL) {
|
||||
delete m_rtapi;
|
||||
m_rtapi = NULL;
|
||||
}
|
||||
#if defined(__UNIX_JACK__)
|
||||
if (_api == airtaudio::api::UNIX_JACK) {
|
||||
m_rtapi = new airtaudio::api::Jack();
|
||||
for (auto &it :m_apiAvaillable) {
|
||||
if (_api == it.first) {
|
||||
m_rtapi = it.second();
|
||||
if (m_rtapi != NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO : An eror occured ...
|
||||
}
|
||||
|
||||
|
||||
airtaudio::Interface::Interface(void) :
|
||||
m_rtapi(NULL) {
|
||||
#if defined(__UNIX_JACK__)
|
||||
addInterface(airtaudio::api::UNIX_JACK, airtaudio::api::Jack::Create);
|
||||
#endif
|
||||
#if defined(__LINUX_ALSA__)
|
||||
if (_api == airtaudio::api::LINUX_ALSA) {
|
||||
m_rtapi = new airtaudio::api::Alsa();
|
||||
}
|
||||
addInterface(airtaudio::api::LINUX_ALSA, airtaudio::api::Alsa::Create);
|
||||
#endif
|
||||
#if defined(__LINUX_PULSE__)
|
||||
if (_api == airtaudio::api::LINUX_PULSE) {
|
||||
m_rtapi = new airtaudio::api::Pulse();
|
||||
}
|
||||
addInterface(airtaudio::api::LINUX_PULSE, airtaudio::api::Pulse::Create);
|
||||
#endif
|
||||
#if defined(__LINUX_OSS__)
|
||||
if (_api == airtaudio::api::LINUX_OSS) {
|
||||
m_rtapi = new airtaudio::api::Oss();
|
||||
}
|
||||
addInterface(airtaudio::api::LINUX_OSS, airtaudio::api::Oss::Create);
|
||||
#endif
|
||||
#if defined(__WINDOWS_ASIO__)
|
||||
if (_api == airtaudio::api::WINDOWS_ASIO) {
|
||||
m_rtapi = new airtaudio::api::Asio();
|
||||
}
|
||||
addInterface(airtaudio::api::WINDOWS_ASIO, airtaudio::api::Asio::Create);
|
||||
#endif
|
||||
#if defined(__WINDOWS_DS__)
|
||||
if (_api == airtaudio::api::WINDOWS_DS) {
|
||||
m_rtapi = new airtaudio::api::Ds();
|
||||
}
|
||||
addInterface(airtaudio::api::WINDOWS_DS, airtaudio::api::Ds::Create);
|
||||
#endif
|
||||
#if defined(__MACOSX_CORE__)
|
||||
if (_api == airtaudio::api::MACOSX_CORE) {
|
||||
m_rtapi = new airtaudio::api::Core();
|
||||
}
|
||||
addInterface(airtaudio::api::MACOSX_CORE, airtaudio::api::Core::Create);
|
||||
#endif
|
||||
#if defined(__AIRTAUDIO_DUMMY__)
|
||||
if (_api == rtaudio::RTAUDIO_DUMMY) {
|
||||
m_rtapi = new airtaudio::api::Dummy();
|
||||
}
|
||||
addInterface(airtaudio::api::RTAUDIO_DUMMY, airtaudio::api::Dummy::Create);
|
||||
#endif
|
||||
}
|
||||
|
||||
airtaudio::Interface::Interface(airtaudio::api::type _api) :
|
||||
m_rtapi(NULL) {
|
||||
void airtaudio::Interface::addInterface(airtaudio::api::type _api, Api* (*_callbackCreate)(void)) {
|
||||
m_apiAvaillable.push_back(std::pair<airtaudio::api::type, Api* (*)(void)>(_api, _callbackCreate));
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type _api) {
|
||||
if (m_rtapi != NULL) {
|
||||
std::cerr << "\nInterface already started ...!\n" << std::endl;
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
if (_api != airtaudio::api::UNSPECIFIED) {
|
||||
// Attempt to open the specified API.
|
||||
openRtApi(_api);
|
||||
if (m_rtapi != NULL) {
|
||||
return;
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
// No compiled support for specified API value. Issue a debug
|
||||
// warning and continue as if no API was specified.
|
||||
std::cerr << "\nRtAudio: no compiled support for specified API argument!\n" << std::endl;
|
||||
return airtaudio::errorFail;
|
||||
}
|
||||
// Iterate through the compiled APIs and return as soon as we find
|
||||
// one with at least one device or we reach the end of the list.
|
||||
std::vector<airtaudio::api::type> apis = getCompiledApi();
|
||||
for (uint32_t iii=0; iii<apis.size(); ++iii) {
|
||||
openRtApi(apis[iii]);
|
||||
for (auto &it : apis) {
|
||||
openRtApi(it);
|
||||
if (m_rtapi->getDeviceCount() != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_rtapi != NULL) {
|
||||
return;
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
// It should not be possible to get here because the preprocessor
|
||||
// definition __AIRTAUDIO_DUMMY__ is automatically defined if no
|
||||
// API-specific definitions are passed to the compiler. But just in
|
||||
// case something weird happens, we'll print out an error message.
|
||||
// TODO : Set it in error ...
|
||||
std::cout << "\nRtAudio: no compiled API support found ... critical error!!\n\n";
|
||||
return airtaudio::errorFail;
|
||||
}
|
||||
|
||||
airtaudio::Interface::~Interface(void) {
|
||||
@ -126,16 +109,16 @@ airtaudio::Interface::~Interface(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void airtaudio::Interface::openStream(airtaudio::StreamParameters* _outputParameters,
|
||||
airtaudio::StreamParameters* _inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t* _bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void* _userData,
|
||||
airtaudio::StreamOptions* _options,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback)
|
||||
{
|
||||
enum airtaudio::errorType airtaudio::Interface::openStream(
|
||||
airtaudio::StreamParameters* _outputParameters,
|
||||
airtaudio::StreamParameters* _inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t* _bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void* _userData,
|
||||
airtaudio::StreamOptions* _options,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ namespace airtaudio {
|
||||
* attempts to make a "logical" API selection.
|
||||
*/
|
||||
class Interface {
|
||||
protected:
|
||||
std::vector<std::pair<airtaudio::api::type, Api* (*)(void)>> m_apiAvaillable;
|
||||
protected:
|
||||
airtaudio::Api *m_rtapi;
|
||||
public:
|
||||
@ -51,18 +53,12 @@ namespace airtaudio {
|
||||
* the enumerated list values. Note that there can be more than one
|
||||
* API compiled for certain operating systems.
|
||||
*/
|
||||
static std::vector<airtaudio::api::type> getCompiledApi(void);
|
||||
std::vector<airtaudio::api::type> getCompiledApi(void);
|
||||
/**
|
||||
* @brief The class constructor.
|
||||
*
|
||||
* The constructor performs minor initialization tasks. No exceptions
|
||||
* can be thrown.
|
||||
*
|
||||
* If no API argument is specified and multiple API support has been
|
||||
* compiled, the default order of use is JACK, ALSA, OSS (Linux
|
||||
* systems) and ASIO, DS (Windows systems).
|
||||
* @note the creating of the basic instance is done by Instanciate
|
||||
*/
|
||||
Interface(airtaudio::api::type _api = airtaudio::api::UNSPECIFIED);
|
||||
Interface(void);
|
||||
/**
|
||||
* @brief The destructor.
|
||||
*
|
||||
@ -70,6 +66,16 @@ namespace airtaudio {
|
||||
* automatically.
|
||||
*/
|
||||
~Interface(void);
|
||||
/**
|
||||
* @brief Add an interface of the Possible List.
|
||||
* @param[in] _api Type of the interface.
|
||||
* @param[in] _callbackCreate API creation callback.
|
||||
*/
|
||||
void addInterface(airtaudio::api::type _api, Api* (*_callbackCreate)(void));
|
||||
/**
|
||||
* @brief Create an interface instance
|
||||
*/
|
||||
enum airtaudio::errorType instanciate(airtaudio::api::type _api = airtaudio::api::UNSPECIFIED);
|
||||
/**
|
||||
* @return the audio API specifier for the current instance of airtaudio.
|
||||
*/
|
||||
@ -179,15 +185,15 @@ namespace airtaudio {
|
||||
* @param _errorCallback A client-defined function that will be invoked
|
||||
* when an error has occured.
|
||||
*/
|
||||
void openStream(airtaudio::StreamParameters *_outputParameters,
|
||||
airtaudio::StreamParameters *_inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t *_bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void *_userData = NULL,
|
||||
airtaudio::StreamOptions *_options = NULL,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback = NULL);
|
||||
enum airtaudio::errorType openStream(airtaudio::StreamParameters *_outputParameters,
|
||||
airtaudio::StreamParameters *_inputParameters,
|
||||
airtaudio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t *_bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
void *_userData = NULL,
|
||||
airtaudio::StreamOptions *_options = NULL,
|
||||
airtaudio::AirTAudioErrorCallback _errorCallback = NULL);
|
||||
|
||||
/**
|
||||
* @brief A function that closes a stream and frees any associated stream memory.
|
||||
@ -195,7 +201,7 @@ namespace airtaudio {
|
||||
* If a stream is not open, this function issues a warning and
|
||||
* returns (no exception is thrown).
|
||||
*/
|
||||
void closeStream(void) {
|
||||
enum airtaudio::errorType closeStream(void) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -209,7 +215,7 @@ namespace airtaudio {
|
||||
* stream is not open. A warning is issued if the stream is already
|
||||
* running.
|
||||
*/
|
||||
void startStream(void) {
|
||||
enum airtaudio::errorType startStream(void) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -223,7 +229,7 @@ namespace airtaudio {
|
||||
* stream is not open. A warning is issued if the stream is already
|
||||
* stopped.
|
||||
*/
|
||||
void stopStream(void) {
|
||||
enum airtaudio::errorType stopStream(void) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -236,7 +242,7 @@ namespace airtaudio {
|
||||
* stream is not open. A warning is issued if the stream is already
|
||||
* stopped.
|
||||
*/
|
||||
void abortStream(void) {
|
||||
enum airtaudio::errorType abortStream(void) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -301,6 +307,9 @@ namespace airtaudio {
|
||||
* @brief Specify whether warning messages should be printed to stderr.
|
||||
*/
|
||||
void showWarnings(bool _value = true) {
|
||||
if (m_rtapi == NULL) {
|
||||
return;
|
||||
}
|
||||
m_rtapi->showWarnings(_value);
|
||||
}
|
||||
protected:
|
||||
|
@ -14,6 +14,11 @@
|
||||
#include <airtaudio/Interface.h>
|
||||
#include <limits.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Alsa::Create(void) {
|
||||
return new airtaudio::api::Alsa();
|
||||
}
|
||||
|
||||
|
||||
// A structure to hold various information related to the ALSA API
|
||||
// implementation.
|
||||
struct AlsaHandle {
|
||||
@ -370,13 +375,13 @@ void airtaudio::api::Alsa::saveDeviceInfo(void) {
|
||||
}
|
||||
|
||||
bool airtaudio::api::Alsa::probeDeviceOpen(uint32_t _device,
|
||||
airtaudio::api::StreamMode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
airtaudio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options) {
|
||||
airtaudio::api::StreamMode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
airtaudio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options) {
|
||||
#if defined(__RTAUDIO_DEBUG__)
|
||||
snd_output_t *out;
|
||||
snd_output_stdio_attach(&out, stderr, 0);
|
||||
@ -818,7 +823,7 @@ error:
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::closeStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::closeStream(void) {
|
||||
if (m_stream.state == STREAM_CLOSED) {
|
||||
m_errorText = "airtaudio::api::Alsa::closeStream(): no open stream to close!";
|
||||
error(airtaudio::errorWarning);
|
||||
@ -871,7 +876,7 @@ void airtaudio::api::Alsa::closeStream(void) {
|
||||
m_stream.state = STREAM_CLOSED;
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::startStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::startStream(void) {
|
||||
// This method calls snd_pcm_prepare if the device isn't already in that state.
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_RUNNING) {
|
||||
@ -918,7 +923,7 @@ unlock:
|
||||
error(airtaudio::errorSystemError);
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::stopStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::stopStream(void) {
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_STOPPED) {
|
||||
m_errorText = "airtaudio::api::Alsa::stopStream(): the stream is already stopped!";
|
||||
@ -960,7 +965,7 @@ unlock:
|
||||
error(airtaudio::errorSystemError);
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::abortStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::abortStream(void) {
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_STOPPED) {
|
||||
m_errorText = "airtaudio::api::Alsa::abortStream(): the stream is already stopped!";
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Alsa: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Alsa();
|
||||
~Alsa();
|
||||
@ -20,10 +22,10 @@ namespace airtaudio {
|
||||
}
|
||||
uint32_t getDeviceCount(void);
|
||||
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
||||
void closeStream(void);
|
||||
void startStream(void);
|
||||
void stopStream(void);
|
||||
void abortStream(void);
|
||||
enum airtaudio::errorType closeStream(void);
|
||||
enum airtaudio::errorType startStream(void);
|
||||
enum airtaudio::errorType stopStream(void);
|
||||
enum airtaudio::errorType abortStream(void);
|
||||
// This function is intended for internal use only. It must be
|
||||
// public because it is called by the internal callback handler,
|
||||
// which is not a member of RtAudio. External use of this function
|
||||
|
@ -11,6 +11,11 @@
|
||||
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Asio::Create(void) {
|
||||
return new airtaudio::api::Asio();
|
||||
}
|
||||
|
||||
|
||||
// The ASIO API is designed around a callback scheme, so this
|
||||
// implementation is similar to that used for OS-X CoreAudio and Linux
|
||||
// Jack. The primary constraint with ASIO is that it only allows
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Asio: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Asio();
|
||||
~Asio();
|
||||
|
@ -17,6 +17,11 @@
|
||||
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Core::Create(void) {
|
||||
return new airtaudio::api::Core();
|
||||
}
|
||||
|
||||
|
||||
// The OS X CoreAudio API is designed to use a separate callback
|
||||
// procedure for each of its audio devices. A single RtAudio duplex
|
||||
// stream using two different devices is supported here, though it
|
||||
|
@ -14,6 +14,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Core: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Core();
|
||||
~Core();
|
||||
|
@ -10,6 +10,11 @@
|
||||
#if defined(__WINDOWS_DS__)
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Ds::Create(void) {
|
||||
return new airtaudio::api::Ds();
|
||||
}
|
||||
|
||||
|
||||
// Modified by Robin Davies, October 2005
|
||||
// - Improvements to DirectX pointer chasing.
|
||||
// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Ds: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Ds(void);
|
||||
~Ds(void);
|
||||
|
@ -8,6 +8,11 @@
|
||||
|
||||
#if defined(__AIRTAUDIO_DUMMY__)
|
||||
|
||||
airtaudio::Api* airtaudio::api::Dummy::Create(void) {
|
||||
return new airtaudio::api::Dummy();
|
||||
}
|
||||
|
||||
|
||||
airtaudio::api::Dummy::Dummy(void) {
|
||||
m_errorText = "airtaudio::api::Dummy: This class provides no functionality.";
|
||||
error(airtaudio::errorWarning);
|
||||
|
@ -14,6 +14,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Dummy: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Dummy(void);
|
||||
airtaudio::api::type getCurrentApi(void) {
|
||||
|
@ -14,6 +14,11 @@
|
||||
#include <airtaudio/Interface.h>
|
||||
#include <string.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Jack::Create(void) {
|
||||
return new airtaudio::api::Jack();
|
||||
}
|
||||
|
||||
|
||||
// JACK is a low-latency audio server, originally written for the
|
||||
// GNU/Linux operating system and now also ported to OS-X. It can
|
||||
// connect a number of different applications to an audio device, as
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Jack: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Jack(void);
|
||||
~Jack(void);
|
||||
|
@ -18,6 +18,10 @@
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Oss::Create(void) {
|
||||
return new airtaudio::api::Oss();
|
||||
}
|
||||
|
||||
static void *ossCallbackHandler(void * ptr);
|
||||
|
||||
// A structure to hold various information related to the OSS API
|
||||
@ -28,8 +32,13 @@ struct OssHandle {
|
||||
bool triggered;
|
||||
pthread_cond_t runnable;
|
||||
|
||||
OssHandle()
|
||||
:triggered(false) { id[0] = 0; id[1] = 0; xrun[0] = false; xrun[1] = false; }
|
||||
OssHandle(void):
|
||||
triggered(false) {
|
||||
id[0] = 0;
|
||||
id[1] = 0;
|
||||
xrun[0] = false;
|
||||
xrun[1] = false;
|
||||
}
|
||||
};
|
||||
|
||||
airtaudio::api::Oss::Oss(void) {
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Oss: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Oss(void);
|
||||
~Oss(void);
|
||||
|
@ -19,6 +19,11 @@
|
||||
#include <pulse/simple.h>
|
||||
#include <cstdio>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Pulse::Create(void) {
|
||||
return new airtaudio::api::Pulse();
|
||||
}
|
||||
|
||||
|
||||
static const uint32_t SUPPORTED_SAMPLERATES[] = {
|
||||
8000,
|
||||
16000,
|
||||
@ -47,7 +52,12 @@ struct PulseAudioHandle {
|
||||
std::thread* thread;
|
||||
std::condition_variable runnable_cv;
|
||||
bool runnable;
|
||||
PulseAudioHandle() : s_play(0), s_rec(0), runnable(false) { }
|
||||
PulseAudioHandle(void) :
|
||||
s_play(0),
|
||||
s_rec(0),
|
||||
runnable(false) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
airtaudio::api::Pulse::~Pulse()
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Pulse: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
~Pulse(void);
|
||||
airtaudio::api::type getCurrentApi(void) {
|
||||
|
@ -25,6 +25,8 @@
|
||||
namespace airtaudio {
|
||||
//! Defined RtError types.
|
||||
enum errorType {
|
||||
errorNone, //!< No error
|
||||
errorFail, //!< An error occure in the operation
|
||||
errorWarning, //!< A non-critical error.
|
||||
errorInvalidUse, //!< The function was called incorrectly.
|
||||
errorSystemError //!< A system error occured.
|
||||
|
Loading…
x
Reference in New Issue
Block a user