[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) {
if (m_rtapi != NULL) {
delete m_rtapi;
m_rtapi = NULL;
}
delete m_rtapi;
m_rtapi = nullptr;
for (auto &it :m_apiAvaillable) {
ATA_ERROR("try open " << it.first);
if (_api == it.first) {
ATA_ERROR(" ==> call it");
m_rtapi = it.second();
if (m_rtapi != NULL) {
if (m_rtapi != nullptr) {
return;
}
}
@ -44,35 +43,46 @@ void airtaudio::Interface::openRtApi(airtaudio::api::type _api) {
airtaudio::Interface::Interface() :
m_rtapi(NULL) {
m_rtapi(nullptr) {
ATA_DEBUG("Add interface:");
#if defined(__UNIX_JACK__)
ATA_DEBUG(" JACK");
addInterface(airtaudio::api::UNIX_JACK, airtaudio::api::Jack::Create);
#endif
#if defined(__LINUX_ALSA__)
ATA_DEBUG(" ALSA");
addInterface(airtaudio::api::LINUX_ALSA, airtaudio::api::Alsa::Create);
#endif
#if defined(__LINUX_PULSE__)
ATA_DEBUG(" PULSE");
addInterface(airtaudio::api::LINUX_PULSE, airtaudio::api::Pulse::Create);
#endif
#if defined(__LINUX_OSS__)
ATA_DEBUG(" OSS");
addInterface(airtaudio::api::LINUX_OSS, airtaudio::api::Oss::Create);
#endif
#if defined(__WINDOWS_ASIO__)
ATA_DEBUG(" ASIO");
addInterface(airtaudio::api::WINDOWS_ASIO, airtaudio::api::Asio::Create);
#endif
#if defined(__WINDOWS_DS__)
ATA_DEBUG(" DS");
addInterface(airtaudio::api::WINDOWS_DS, airtaudio::api::Ds::Create);
#endif
#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
#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
#if defined(__ANDROID_JAVA__)
ATA_DEBUG(" JAVA");
addInterface(airtaudio::api::ANDROID_JAVA, airtaudio::api::Android::Create);
#endif
#if defined(__AIRTAUDIO_DUMMY__)
ATA_DEBUG(" DUMMY");
addInterface(airtaudio::api::RTAUDIO_DUMMY, airtaudio::api::Dummy::Create);
#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) {
ATA_INFO("Instanciate API ...");
if (m_rtapi != NULL) {
if (m_rtapi != nullptr) {
ATA_WARNING("Interface already started ...!");
return airtaudio::errorNone;
}
@ -91,7 +101,7 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
ATA_ERROR("API specified ...");
// Attempt to open the specified API.
openRtApi(_api);
if (m_rtapi != NULL) {
if (m_rtapi != nullptr) {
return airtaudio::errorNone;
}
// 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) {
ATA_INFO("try open ...");
openRtApi(it);
if(m_rtapi == NULL) {
if(m_rtapi == nullptr) {
ATA_ERROR(" ==> can not create ...");
continue;
}
@ -116,7 +126,7 @@ enum airtaudio::errorType airtaudio::Interface::instanciate(airtaudio::api::type
break;
}
}
if (m_rtapi != NULL) {
if (m_rtapi != nullptr) {
return airtaudio::errorNone;
}
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() {
ATA_INFO("Remove interface");
if (m_rtapi != NULL) {
delete m_rtapi;
m_rtapi = NULL;
}
delete m_rtapi;
m_rtapi = nullptr;
}
enum airtaudio::errorType airtaudio::Interface::openStream(
@ -140,7 +148,7 @@ enum airtaudio::errorType airtaudio::Interface::openStream(
airtaudio::AirTAudioCallback _callback,
void* _userData,
airtaudio::StreamOptions* _options) {
if (m_rtapi == NULL) {
if (m_rtapi == nullptr) {
return airtaudio::errorInputNull;
}
return m_rtapi->openStream(_outputParameters,

View File

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