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