[DEV] small change

This commit is contained in:
Edouard DUPIN 2015-01-26 21:52:29 +01:00
parent 00af426a47
commit dd604bc736
2 changed files with 43 additions and 35 deletions

View File

@ -24,16 +24,15 @@ std::vector<airtaudio::api::type> airtaudio::Interface::getCompiledApi() {
void airtaudio::Interface::openRtApi(airtaudio::api::type _api) { void airtaudio::Interface::openRtApi(airtaudio::api::type _api) {
if (m_rtapi != NULL) {
delete m_rtapi; delete m_rtapi;
m_rtapi = NULL; m_rtapi = nullptr;
}
for (auto &it :m_apiAvaillable) { for (auto &it :m_apiAvaillable) {
ATA_ERROR("try open " << it.first); ATA_ERROR("try open " << it.first);
if (_api == it.first) { if (_api == it.first) {
ATA_ERROR(" ==> call it"); ATA_ERROR(" ==> call it");
m_rtapi = it.second(); m_rtapi = it.second();
if (m_rtapi != NULL) { if (m_rtapi != nullptr) {
return; return;
} }
} }
@ -44,35 +43,46 @@ void airtaudio::Interface::openRtApi(airtaudio::api::type _api) {
airtaudio::Interface::Interface() : airtaudio::Interface::Interface() :
m_rtapi(NULL) { m_rtapi(nullptr) {
ATA_DEBUG("Add interface:");
#if defined(__UNIX_JACK__) #if defined(__UNIX_JACK__)
ATA_DEBUG(" JACK");
addInterface(airtaudio::api::UNIX_JACK, airtaudio::api::Jack::Create); addInterface(airtaudio::api::UNIX_JACK, airtaudio::api::Jack::Create);
#endif #endif
#if defined(__LINUX_ALSA__) #if defined(__LINUX_ALSA__)
ATA_DEBUG(" ALSA");
addInterface(airtaudio::api::LINUX_ALSA, airtaudio::api::Alsa::Create); addInterface(airtaudio::api::LINUX_ALSA, airtaudio::api::Alsa::Create);
#endif #endif
#if defined(__LINUX_PULSE__) #if defined(__LINUX_PULSE__)
ATA_DEBUG(" PULSE");
addInterface(airtaudio::api::LINUX_PULSE, airtaudio::api::Pulse::Create); addInterface(airtaudio::api::LINUX_PULSE, airtaudio::api::Pulse::Create);
#endif #endif
#if defined(__LINUX_OSS__) #if defined(__LINUX_OSS__)
ATA_DEBUG(" OSS");
addInterface(airtaudio::api::LINUX_OSS, airtaudio::api::Oss::Create); addInterface(airtaudio::api::LINUX_OSS, airtaudio::api::Oss::Create);
#endif #endif
#if defined(__WINDOWS_ASIO__) #if defined(__WINDOWS_ASIO__)
ATA_DEBUG(" ASIO");
addInterface(airtaudio::api::WINDOWS_ASIO, airtaudio::api::Asio::Create); addInterface(airtaudio::api::WINDOWS_ASIO, airtaudio::api::Asio::Create);
#endif #endif
#if defined(__WINDOWS_DS__) #if defined(__WINDOWS_DS__)
ATA_DEBUG(" DS");
addInterface(airtaudio::api::WINDOWS_DS, airtaudio::api::Ds::Create); addInterface(airtaudio::api::WINDOWS_DS, airtaudio::api::Ds::Create);
#endif #endif
#if defined(__MACOSX_CORE__) #if defined(__MACOSX_CORE__)
addInterface(airtaudio::api::MACOSX_CORE, airtaudio::api::Core::Create); ATA_DEBUG(" MACOSX_CORE");
addInterface(airtaudio::api::MACOSX_CORE, airtaudio::api::Core::Create);
#endif #endif
#if defined(__IOS_CORE__) #if defined(__IOS_CORE__)
addInterface(airtaudio::api::IOS_CORE, airtaudio::api::CoreIos::Create); ATA_DEBUG(" IOS_CORE");
addInterface(airtaudio::api::IOS_CORE, airtaudio::api::CoreIos::Create);
#endif #endif
#if defined(__ANDROID_JAVA__) #if defined(__ANDROID_JAVA__)
ATA_DEBUG(" JAVA");
addInterface(airtaudio::api::ANDROID_JAVA, airtaudio::api::Android::Create); addInterface(airtaudio::api::ANDROID_JAVA, airtaudio::api::Android::Create);
#endif #endif
#if defined(__AIRTAUDIO_DUMMY__) #if defined(__AIRTAUDIO_DUMMY__)
ATA_DEBUG(" DUMMY");
addInterface(airtaudio::api::RTAUDIO_DUMMY, airtaudio::api::Dummy::Create); addInterface(airtaudio::api::RTAUDIO_DUMMY, airtaudio::api::Dummy::Create);
#endif #endif
} }
@ -83,7 +93,7 @@ void airtaudio::Interface::addInterface(airtaudio::api::type _api, Api* (*_callb
enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type _api) { enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type _api) {
ATA_INFO("Instanciate API ..."); ATA_INFO("Instanciate API ...");
if (m_rtapi != NULL) { if (m_rtapi != nullptr) {
ATA_WARNING("Interface already started ...!"); ATA_WARNING("Interface already started ...!");
return airtaudio::errorNone; return airtaudio::errorNone;
} }
@ -91,7 +101,7 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
ATA_ERROR("API specified ..."); ATA_ERROR("API specified ...");
// Attempt to open the specified API. // Attempt to open the specified API.
openRtApi(_api); openRtApi(_api);
if (m_rtapi != NULL) { if (m_rtapi != nullptr) {
return airtaudio::errorNone; return airtaudio::errorNone;
} }
// No compiled support for specified API value. Issue a debug // No compiled support for specified API value. Issue a debug
@ -107,7 +117,7 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
for (auto &it : apis) { for (auto &it : apis) {
ATA_INFO("try open ..."); ATA_INFO("try open ...");
openRtApi(it); openRtApi(it);
if(m_rtapi == NULL) { if(m_rtapi == nullptr) {
ATA_ERROR(" ==> can not create ..."); ATA_ERROR(" ==> can not create ...");
continue; continue;
} }
@ -116,7 +126,7 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
break; break;
} }
} }
if (m_rtapi != NULL) { if (m_rtapi != nullptr) {
return airtaudio::errorNone; return airtaudio::errorNone;
} }
ATA_ERROR("RtAudio: no compiled API support found ... critical error!!"); ATA_ERROR("RtAudio: no compiled API support found ... critical error!!");
@ -125,10 +135,8 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
airtaudio::Interface::~Interface() { airtaudio::Interface::~Interface() {
ATA_INFO("Remove interface"); ATA_INFO("Remove interface");
if (m_rtapi != NULL) { delete m_rtapi;
delete m_rtapi; m_rtapi = nullptr;
m_rtapi = NULL;
}
} }
enum airtaudio::errorType airtaudio::Interface::openStream( enum airtaudio::errorType airtaudio::Interface::openStream(
@ -140,7 +148,7 @@ enum airtaudio::errorType airtaudio::Interface::openStream(
airtaudio::AirTAudioCallback _callback, airtaudio::AirTAudioCallback _callback,
void* _userData, void* _userData,
airtaudio::StreamOptions* _options) { airtaudio::StreamOptions* _options) {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::errorInputNull; return airtaudio::errorInputNull;
} }
return m_rtapi->openStream(_outputParameters, return m_rtapi->openStream(_outputParameters,

View File

@ -82,7 +82,7 @@ namespace airtaudio {
* @return the audio API specifier for the current instance of airtaudio. * @return the audio API specifier for the current instance of airtaudio.
*/ */
airtaudio::api::type getCurrentApi() { airtaudio::api::type getCurrentApi() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::api::UNSPECIFIED; return airtaudio::api::UNSPECIFIED;
} }
return m_rtapi->getCurrentApi(); return m_rtapi->getCurrentApi();
@ -95,7 +95,7 @@ namespace airtaudio {
* a system error occurs during processing, a warning will be issued. * a system error occurs during processing, a warning will be issued.
*/ */
uint32_t getDeviceCount() { uint32_t getDeviceCount() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0; return 0;
} }
return m_rtapi->getDeviceCount(); return m_rtapi->getDeviceCount();
@ -112,7 +112,7 @@ namespace airtaudio {
* @return An airtaudio::DeviceInfo structure for a specified device number. * @return An airtaudio::DeviceInfo structure for a specified device number.
*/ */
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) { airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::DeviceInfo(); return airtaudio::DeviceInfo();
} }
return m_rtapi->getDeviceInfo(_device); return m_rtapi->getDeviceInfo(_device);
@ -127,7 +127,7 @@ namespace airtaudio {
* before attempting to open a stream. * before attempting to open a stream.
*/ */
uint32_t getDefaultOutputDevice() { uint32_t getDefaultOutputDevice() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0; return 0;
} }
return m_rtapi->getDefaultOutputDevice(); return m_rtapi->getDefaultOutputDevice();
@ -142,7 +142,7 @@ namespace airtaudio {
* before attempting to open a stream. * before attempting to open a stream.
*/ */
uint32_t getDefaultInputDevice() { uint32_t getDefaultInputDevice() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0; return 0;
} }
return m_rtapi->getDefaultInputDevice(); return m_rtapi->getDefaultInputDevice();
@ -157,12 +157,12 @@ namespace airtaudio {
* @param _outputParameters Specifies output stream parameters to use * @param _outputParameters Specifies output stream parameters to use
* when opening a stream, including a device ID, number of channels, * when opening a stream, including a device ID, number of channels,
* and starting channel number. For input-only streams, this * and starting channel number. For input-only streams, this
* argument should be NULL. The device ID is an index value between * argument should be nullptr. The device ID is an index value between
* 0 and getDeviceCount() - 1. * 0 and getDeviceCount() - 1.
* @param _inputParameters Specifies input stream parameters to use * @param _inputParameters Specifies input stream parameters to use
* when opening a stream, including a device ID, number of channels, * when opening a stream, including a device ID, number of channels,
* and starting channel number. For output-only streams, this * and starting channel number. For output-only streams, this
* argument should be NULL. The device ID is an index value between * argument should be nullptr. The device ID is an index value between
* 0 and getDeviceCount() - 1. * 0 and getDeviceCount() - 1.
* @param _format An airtaudio::format specifying the desired sample data format. * @param _format An airtaudio::format specifying the desired sample data format.
* @param _sampleRate The desired sample rate (sample frames per second). * @param _sampleRate The desired sample rate (sample frames per second).
@ -193,8 +193,8 @@ namespace airtaudio {
uint32_t _sampleRate, uint32_t _sampleRate,
uint32_t *_bufferFrames, uint32_t *_bufferFrames,
airtaudio::AirTAudioCallback _callback, airtaudio::AirTAudioCallback _callback,
void *_userData = NULL, void *_userData = nullptr,
airtaudio::StreamOptions *_options = NULL); airtaudio::StreamOptions *_options = nullptr);
/** /**
* @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.
@ -203,7 +203,7 @@ namespace airtaudio {
* returns (no exception is thrown). * returns (no exception is thrown).
*/ */
enum airtaudio::errorType closeStream() { enum airtaudio::errorType closeStream() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::errorInputNull; return airtaudio::errorInputNull;
} }
return m_rtapi->closeStream(); return m_rtapi->closeStream();
@ -217,7 +217,7 @@ namespace airtaudio {
* running. * running.
*/ */
enum airtaudio::errorType startStream() { enum airtaudio::errorType startStream() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::errorInputNull; return airtaudio::errorInputNull;
} }
return m_rtapi->startStream(); return m_rtapi->startStream();
@ -231,7 +231,7 @@ namespace airtaudio {
* stopped. * stopped.
*/ */
enum airtaudio::errorType stopStream() { enum airtaudio::errorType stopStream() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::errorInputNull; return airtaudio::errorInputNull;
} }
return m_rtapi->stopStream(); return m_rtapi->stopStream();
@ -244,7 +244,7 @@ namespace airtaudio {
* stopped. * stopped.
*/ */
enum airtaudio::errorType abortStream() { enum airtaudio::errorType abortStream() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return airtaudio::errorInputNull; return airtaudio::errorInputNull;
} }
return m_rtapi->abortStream(); return m_rtapi->abortStream();
@ -253,7 +253,7 @@ namespace airtaudio {
* @return true if a stream is open and false if not. * @return true if a stream is open and false if not.
*/ */
bool isStreamOpen() const { bool isStreamOpen() const {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return false; return false;
} }
return m_rtapi->isStreamOpen(); return m_rtapi->isStreamOpen();
@ -262,7 +262,7 @@ namespace airtaudio {
* @return true if the stream is running and false if it is stopped or not open. * @return true if the stream is running and false if it is stopped or not open.
*/ */
bool isStreamRunning() const { bool isStreamRunning() const {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return false; return false;
} }
return m_rtapi->isStreamRunning(); return m_rtapi->isStreamRunning();
@ -272,7 +272,7 @@ namespace airtaudio {
* @return the number of elapsed seconds since the stream was started. * @return the number of elapsed seconds since the stream was started.
*/ */
double getStreamTime() { double getStreamTime() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0.0; return 0.0;
} }
return m_rtapi->getStreamTime(); return m_rtapi->getStreamTime();
@ -287,7 +287,7 @@ namespace airtaudio {
* @return The internal stream latency in sample frames. * @return The internal stream latency in sample frames.
*/ */
long getStreamLatency() { long getStreamLatency() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0; return 0;
} }
return m_rtapi->getStreamLatency(); return m_rtapi->getStreamLatency();
@ -299,7 +299,7 @@ namespace airtaudio {
* @return Returns actual sample rate in use by the stream. * @return Returns actual sample rate in use by the stream.
*/ */
uint32_t getStreamSampleRate() { uint32_t getStreamSampleRate() {
if (m_rtapi == NULL) { if (m_rtapi == nullptr) {
return 0; return 0;
} }
return m_rtapi->getStreamSampleRate(); return m_rtapi->getStreamSampleRate();