From bc78a1858a32bca9dbd42227940d07a7c9d4a095 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 29 Apr 2016 23:16:07 +0200 Subject: [PATCH] [DEV] update the change on 'enum' to 'enum class' --- audio/orchestra/Api.cpp | 10 +++--- audio/orchestra/Api.h | 4 +-- audio/orchestra/Interface.cpp | 24 +++++++------- audio/orchestra/Interface.h | 4 +-- audio/orchestra/api/Alsa.cpp | 62 +++++++++++++++++------------------ audio/orchestra/api/Alsa.h | 2 +- audio/orchestra/api/Android.h | 2 +- audio/orchestra/api/Asio.cpp | 38 ++++++++++----------- audio/orchestra/api/Asio.h | 2 +- audio/orchestra/api/Core.cpp | 38 ++++++++++----------- audio/orchestra/api/Core.h | 2 +- audio/orchestra/api/CoreIos.h | 2 +- audio/orchestra/api/Ds.cpp | 34 +++++++++---------- audio/orchestra/api/Ds.h | 2 +- audio/orchestra/api/Dummy.h | 2 +- audio/orchestra/api/Jack.cpp | 37 ++++++++++----------- audio/orchestra/api/Jack.h | 2 +- audio/orchestra/api/Pulse.cpp | 38 ++++++++++----------- audio/orchestra/api/Pulse.h | 2 +- audio/orchestra/state.h | 10 +++--- audio/orchestra/status.cpp | 2 +- audio/orchestra/status.h | 8 ++--- audio/orchestra/type.cpp | 25 +++++++------- audio/orchestra/type.h | 22 ++++++------- 24 files changed, 184 insertions(+), 190 deletions(-) diff --git a/audio/orchestra/Api.cpp b/audio/orchestra/Api.cpp index 774f125..a86d8f9 100644 --- a/audio/orchestra/Api.cpp +++ b/audio/orchestra/Api.cpp @@ -47,7 +47,7 @@ audio::orchestra::Api::Api() : m_deviceBuffer(nullptr) { m_device[0] = 11111; m_device[1] = 11111; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; m_mode = audio::orchestra::mode_unknow; } @@ -69,7 +69,7 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra: uint32_t* _bufferFrames, audio::orchestra::AirTAudioCallback _callback, const audio::orchestra::StreamOptions& _options) { - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { ATA_ERROR("a stream is already open!"); return audio::orchestra::error_invalidUse; } @@ -168,7 +168,7 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra: } m_callback = _callback; //_options.numberOfBuffers = m_nBuffers; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; return audio::orchestra::error_none; } @@ -237,7 +237,7 @@ uint32_t audio::orchestra::Api::getStreamSampleRate() { } enum audio::orchestra::error audio::orchestra::Api::verifyStream() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("a stream is not open!"); return audio::orchestra::error_invalidUse; } @@ -246,7 +246,7 @@ enum audio::orchestra::error audio::orchestra::Api::verifyStream() { void audio::orchestra::Api::clearStreamInfo() { m_mode = audio::orchestra::mode_unknow; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; m_sampleRate = 0; m_bufferSize = 0; m_nBuffers = 0; diff --git a/audio/orchestra/Api.h b/audio/orchestra/Api.h index a41413f..aacc4fd 100644 --- a/audio/orchestra/Api.h +++ b/audio/orchestra/Api.h @@ -78,10 +78,10 @@ namespace audio { uint32_t getStreamSampleRate(); virtual audio::Time getStreamTime(); bool isStreamOpen() const { - return m_state != audio::orchestra::state_closed; + return m_state != audio::orchestra::state::closed; } bool isStreamRunning() const { - return m_state == audio::orchestra::state_running; + return m_state == audio::orchestra::state::running; } protected: diff --git a/audio/orchestra/Interface.cpp b/audio/orchestra/Interface.cpp index 524b3d5..28ff2c7 100644 --- a/audio/orchestra/Interface.cpp +++ b/audio/orchestra/Interface.cpp @@ -55,31 +55,31 @@ audio::orchestra::Interface::Interface() : m_api(nullptr) { ATA_DEBUG("Add interface:"); #if defined(ORCHESTRA_BUILD_JACK) - addInterface(audio::orchestra::type_jack, audio::orchestra::api::Jack::create); + addInterface(audio::orchestra::typeJack, audio::orchestra::api::Jack::create); #endif #if defined(ORCHESTRA_BUILD_ALSA) - addInterface(audio::orchestra::type_alsa, audio::orchestra::api::Alsa::create); + addInterface(audio::orchestra::typeAlsa, audio::orchestra::api::Alsa::create); #endif #if defined(ORCHESTRA_BUILD_PULSE) - addInterface(audio::orchestra::type_pulse, audio::orchestra::api::Pulse::create); + addInterface(audio::orchestra::typePulse, audio::orchestra::api::Pulse::create); #endif #if defined(ORCHESTRA_BUILD_ASIO) - addInterface(audio::orchestra::type_asio, audio::orchestra::api::Asio::create); + addInterface(audio::orchestra::typeAsio, audio::orchestra::api::Asio::create); #endif #if defined(ORCHESTRA_BUILD_DS) - addInterface(audio::orchestra::type_ds, audio::orchestra::api::Ds::create); + addInterface(audio::orchestra::typeDs, audio::orchestra::api::Ds::create); #endif #if defined(ORCHESTRA_BUILD_MACOSX_CORE) - addInterface(audio::orchestra::type_coreOSX, audio::orchestra::api::Core::create); + addInterface(audio::orchestra::typeCoreOSX, audio::orchestra::api::Core::create); #endif #if defined(ORCHESTRA_BUILD_IOS_CORE) - addInterface(audio::orchestra::type_coreIOS, audio::orchestra::api::CoreIos::create); + addInterface(audio::orchestra::typeCoreIOS, audio::orchestra::api::CoreIos::create); #endif #if defined(ORCHESTRA_BUILD_JAVA) - addInterface(audio::orchestra::type_java, audio::orchestra::api::Android::create); + addInterface(audio::orchestra::typeJava, audio::orchestra::api::Android::create); #endif #if defined(ORCHESTRA_BUILD_DUMMY) - addInterface(audio::orchestra::type_dummy, audio::orchestra::api::Dummy::create); + addInterface(audio::orchestra::typeDummy, audio::orchestra::api::Dummy::create); #endif } @@ -103,7 +103,7 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(const std: ATA_WARNING("Interface already started!"); return audio::orchestra::error_none; } - if (_api != audio::orchestra::type_undefined) { + if (_api != audio::orchestra::typeUndefined) { ATA_INFO("API specified : " << _api); // Attempt to open the specified API. openApi(_api); @@ -181,8 +181,8 @@ bool audio::orchestra::Interface::isMasterOf(audio::orchestra::Interface& _inter ATA_ERROR("Can not link 2 Interface with not the same Low level type (?)");//" << _interface.m_adac->getCurrentApi() << " != " << m_adac->getCurrentApi() << ")"); return false; } - if (m_api->getCurrentApi() != audio::orchestra::type_alsa) { - ATA_ERROR("Link 2 device together work only if the interafec is ?");// << audio::orchestra::type_alsa << " not for " << m_api->getCurrentApi()); + if (m_api->getCurrentApi() != audio::orchestra::typeAlsa) { + ATA_ERROR("Link 2 device together work only if the interafec is ?");// << audio::orchestra::type::alsa << " not for " << m_api->getCurrentApi()); return false; } return m_api->isMasterOf(_interface.m_api); diff --git a/audio/orchestra/Interface.h b/audio/orchestra/Interface.h index b97943f..8b12aff 100644 --- a/audio/orchestra/Interface.h +++ b/audio/orchestra/Interface.h @@ -66,13 +66,13 @@ namespace audio { /** * @brief Create an interface instance */ - enum audio::orchestra::error instanciate(const std::string& _api = audio::orchestra::type_undefined); + enum audio::orchestra::error instanciate(const std::string& _api = audio::orchestra::typeUndefined); /** * @return the audio API specifier for the current instance of airtaudio. */ const std::string& getCurrentApi() { if (m_api == nullptr) { - return audio::orchestra::type_undefined; + return audio::orchestra::typeUndefined; } return m_api->getCurrentApi(); } diff --git a/audio/orchestra/api/Alsa.cpp b/audio/orchestra/api/Alsa.cpp index e77bc95..30dfecb 100644 --- a/audio/orchestra/api/Alsa.cpp +++ b/audio/orchestra/api/Alsa.cpp @@ -70,7 +70,7 @@ audio::orchestra::api::Alsa::Alsa() : } audio::orchestra::api::Alsa::~Alsa() { - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { closeStream(); } } @@ -322,7 +322,7 @@ foundDevice: snd_ctl_close(chandle); // If a stream is already open, we cannot probe the stream devices. // Thus, use the saved results. - if ( m_state != audio::orchestra::state_closed + if ( m_state != audio::orchestra::state::closed && ( m_device[0] == _device || m_device[1] == _device)) { if (_device >= m_devices.size()) { @@ -795,7 +795,7 @@ bool audio::orchestra::api::Alsa::openName(const std::string& _deviceName, m_nBuffers = periods; ATA_INFO("ALSA NB buffer = " << m_nBuffers); // TODO : m_device[modeToIdTable(_mode)] = _device; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; // Setup the buffer conversion information structure. if (m_doConvertBuffer[modeToIdTable(_mode)]) { setConvertInfo(_mode, _firstChannel); @@ -824,18 +824,18 @@ error: free(m_deviceBuffer); m_deviceBuffer = 0; } - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; return false; } enum audio::orchestra::error audio::orchestra::api::Alsa::closeStream() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("no open stream to close!"); return audio::orchestra::error_warning; } m_private->threadRunning = false; m_mutex.lock(); - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { m_private->runnable = true; m_private->runnable_cv.notify_one(); } @@ -844,8 +844,8 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::closeStream() { m_private->thread->join(); m_private->thread = nullptr; } - if (m_state == audio::orchestra::state_running) { - m_state = audio::orchestra::state_stopped; + if (m_state == audio::orchestra::state::running) { + m_state = audio::orchestra::state::stopped; snd_pcm_drop(m_private->handle); } // close all stream : @@ -861,7 +861,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::closeStream() { m_deviceBuffer = 0; } m_mode = audio::orchestra::mode_unknow; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; return audio::orchestra::error_none; } @@ -872,7 +872,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::startStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { ATA_ERROR("the stream is already running!"); return audio::orchestra::error_warning; } @@ -891,7 +891,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::startStream() { goto unlock; } } - m_state = audio::orchestra::state_running; + m_state = audio::orchestra::state::running; unlock: m_private->runnable = true; m_private->runnable_cv.notify_one(); @@ -905,11 +905,11 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::stopStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; std::unique_lock lck(m_mutex); int32_t result = 0; if (m_mode == audio::orchestra::mode_output) { @@ -932,11 +932,11 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::abortStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; std::unique_lock lck(m_mutex); int32_t result = 0; result = snd_pcm_drop(m_private->handle); @@ -979,12 +979,12 @@ static int32_t wait_for_poll(snd_pcm_t* _handle, struct pollfd* _ufds, unsigned void audio::orchestra::api::Alsa::callbackEvent() { // Lock while the system is not started ... - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { std::unique_lock lck(m_mutex); while (!m_private->runnable) { m_private->runnable_cv.wait(lck); } - if (m_state != audio::orchestra::state_running) { + if (m_state != audio::orchestra::state::running) { return; } } @@ -1100,7 +1100,7 @@ audio::Time audio::orchestra::api::Alsa::getStreamTime() { } void audio::orchestra::api::Alsa::callbackEventOneCycleRead() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_CRITICAL("the stream is closed ... this shouldn't happen!"); return; // TODO : notify appl: audio::orchestra::error_warning; } @@ -1108,7 +1108,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleRead() { audio::Time streamTime; std::vector status; if (m_private->xrun[0] == true) { - status.push_back(audio::orchestra::status_underflow); + status.push_back(audio::orchestra::status::underflow); m_private->xrun[0] = false; } int32_t result; @@ -1117,7 +1117,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleRead() { snd_pcm_sframes_t frames; audio::format format; - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { // !!! goto unlock; } @@ -1216,7 +1216,7 @@ unlock: } void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_CRITICAL("the stream is closed ... this shouldn't happen!"); return; // TODO : notify appl: audio::orchestra::error_warning; } @@ -1224,7 +1224,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() { audio::Time streamTime; std::vector status; if (m_private->xrun[1] == true) { - status.push_back(audio::orchestra::status_overflow); + status.push_back(audio::orchestra::status::overflow); m_private->xrun[1] = false; } int32_t result; @@ -1233,7 +1233,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() { snd_pcm_sframes_t frames; audio::format format; - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { // !!! goto unlock; } @@ -1318,7 +1318,7 @@ unlock: } void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_CRITICAL("the stream is closed ... this shouldn't happen!"); return; // TODO : notify appl: audio::orchestra::error_warning; } @@ -1326,7 +1326,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() { audio::Time streamTime; std::vector status; if (m_private->xrun[1] == true) { - status.push_back(audio::orchestra::status_overflow); + status.push_back(audio::orchestra::status::overflow); m_private->xrun[1] = false; } int32_t result; @@ -1335,7 +1335,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() { snd_pcm_sframes_t frames; audio::format format; - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { // !!! goto unlock; } int32_t avail = snd_pcm_avail_update(m_private->handle); @@ -1451,7 +1451,7 @@ unlock: } } void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_CRITICAL("the stream is closed ... this shouldn't happen!"); return; // TODO : notify appl: audio::orchestra::error_warning; } @@ -1459,7 +1459,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() { audio::Time streamTime; std::vector status; if (m_private->xrun[0] == true) { - status.push_back(audio::orchestra::status_underflow); + status.push_back(audio::orchestra::status::underflow); m_private->xrun[0] = false; } int32_t result; @@ -1468,7 +1468,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() { snd_pcm_sframes_t frames; audio::format format; - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { goto unlock; } { @@ -1572,11 +1572,11 @@ bool audio::orchestra::api::Alsa::isMasterOf(std::shared_ptr can not synchronize ..."); return false; } - if (slave->m_state == audio::orchestra::state_running) { + if (slave->m_state == audio::orchestra::state::running) { ATA_ERROR("The SLAVE stream is already running! ==> can not synchronize ..."); return false; } diff --git a/audio/orchestra/api/Alsa.h b/audio/orchestra/api/Alsa.h index f9f928c..07aa6bc 100644 --- a/audio/orchestra/api/Alsa.h +++ b/audio/orchestra/api/Alsa.h @@ -19,7 +19,7 @@ namespace audio { Alsa(); virtual ~Alsa(); const std::string& getCurrentApi() { - return audio::orchestra::type_alsa; + return audio::orchestra::typeAlsa; } uint32_t getDeviceCount(); private: diff --git a/audio/orchestra/api/Android.h b/audio/orchestra/api/Android.h index 2def509..dfbdf41 100644 --- a/audio/orchestra/api/Android.h +++ b/audio/orchestra/api/Android.h @@ -19,7 +19,7 @@ namespace audio { Android(); virtual ~Android(); const std::string& getCurrentApi() { - return audio::orchestra::type_java; + return audio::orchestra::typeJava; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/Asio.cpp b/audio/orchestra/api/Asio.cpp index 733d715..7e55bee 100644 --- a/audio/orchestra/api/Asio.cpp +++ b/audio/orchestra/api/Asio.cpp @@ -90,7 +90,7 @@ audio::orchestra::api::Asio::Asio() : } audio::orchestra::api::Asio::~Asio() { - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { closeStream(); } if (m_coInitialized) { @@ -116,7 +116,7 @@ rtaudio::DeviceInfo audio::orchestra::api::Asio::getDeviceInfo(uint32_t _device) return info; } // If a stream is already open, we cannot probe other devices. Thus, use the saved results. - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { if (_device >= m_devices.size()) { ATA_ERROR("device ID was not present before stream was opened."); return info; @@ -503,7 +503,7 @@ bool audio::orchestra::api::Asio::open(uint32_t _device, } m_sampleRate = _sampleRate; m_device[modeToIdTable(_mode)] = _device; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; if ( _mode == audio::orchestra::mode_output && _mode == audio::orchestra::mode_input) { // We had already set up an output stream. @@ -550,12 +550,12 @@ error: } enum audio::orchestra::error audio::orchestra::api::Asio::closeStream() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("no open stream to close!"); return audio::orchestra::error_warning; } - if (m_state == audio::orchestra::state_running) { - m_state = audio::orchestra::state_stopped; + if (m_state == audio::orchestra::state::running) { + m_state = audio::orchestra::state::stopped; ASIOStop(); } ASIODisposeBuffers(); @@ -575,7 +575,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::closeStream() { m_deviceBuffer = 0; } m_mode = audio::orchestra::mode_unknow; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; return audio::orchestra::error_none; } @@ -587,7 +587,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::startStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { ATA_ERROR("the stream is already running!"); return audio::orchestra::error_warning; } @@ -599,7 +599,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::startStream() { m_private->drainCounter = 0; m_private->internalDrain = false; ResetEvent(m_private->condition); - m_state = audio::orchestra::state_running; + m_state = audio::orchestra::state::running; asioXRun = false; unlock: stopThreadCalled = false; @@ -613,7 +613,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::stopStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } @@ -623,7 +623,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::stopStream() { WaitForSingleObject(m_private->condition, INFINITE); // block until signaled } } - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; ASIOError result = ASIOStop(); if (result != ASE_OK) { ATA_ERROR("error (" << getAsioErrorString(result) << ") stopping device."); @@ -638,7 +638,7 @@ enum audio::orchestra::error audio::orchestra::api::Asio::abortStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); error(audio::orchestra::error_warning); return; @@ -666,18 +666,18 @@ static unsigned __stdcall asioStopStream(void *_ptr) { } bool audio::orchestra::api::Asio::callbackEvent(long bufferIndex) { - if ( m_state == audio::orchestra::state_stopped - || m_state == audio::orchestra::state_stopping) { + if ( m_state == audio::orchestra::state::stopped + || m_state == audio::orchestra::state::stopping) { return true; } - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("the stream is closed ... this shouldn't happen!"); return false; } CallbackInfo *info = (CallbackInfo *) &m_callbackInfo; // Check if we were draining the stream and signal if finished. if (m_private->drainCounter > 3) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; if (m_private->internalDrain == false) { SetEvent(m_private->condition); } else { // spawn a thread to stop the stream @@ -697,11 +697,11 @@ bool audio::orchestra::api::Asio::callbackEvent(long bufferIndex) { audio::Time streamTime = getStreamTime(); std::vectorcallback(m_userBuffer[1], @@ -711,7 +711,7 @@ bool audio::orchestra::api::Asio::callbackEvent(long bufferIndex) { m_bufferSize, status); if (cbReturnValue == 2) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; m_private->drainCounter = 2; unsigned threadId; m_callbackInfo.thread = _beginthreadex(nullptr, diff --git a/audio/orchestra/api/Asio.h b/audio/orchestra/api/Asio.h index e7c2073..eb98d81 100644 --- a/audio/orchestra/api/Asio.h +++ b/audio/orchestra/api/Asio.h @@ -18,7 +18,7 @@ namespace audio { Asio(); virtual ~Asio(); const std::string& getCurrentApi() { - return audio::orchestra::WINDOWS_ASIO; + return audio::orchestra::typeAsio; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/Core.cpp b/audio/orchestra/api/Core.cpp index bc008d1..6e85904 100644 --- a/audio/orchestra/api/Core.cpp +++ b/audio/orchestra/api/Core.cpp @@ -88,7 +88,7 @@ audio::orchestra::api::Core::~Core() { // The subclass destructor gets called before the base class // destructor, so close an existing stream before deallocating // apiDeviceId memory. - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { closeStream(); } } @@ -828,7 +828,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device, } m_sampleRate = _sampleRate; m_device[modeToIdTable(_mode)] = _device; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; ATA_VERBOSE("Set state as stopped"); // Setup the buffer conversion information structure. if (m_doConvertBuffer[modeToIdTable(_mode)]) { @@ -872,19 +872,19 @@ error: free(m_deviceBuffer); m_deviceBuffer = 0; } - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; ATA_VERBOSE("Set state as closed"); return false; } enum audio::orchestra::error audio::orchestra::api::Core::closeStream() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("no open stream to close!"); return audio::orchestra::error_warning; } if ( m_mode == audio::orchestra::mode_output || m_mode == audio::orchestra::mode_duplex) { - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { AudioDeviceStop(m_private->id[0], &audio::orchestra::api::Core::callbackEvent); } #if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) @@ -897,7 +897,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::closeStream() { if ( m_mode == audio::orchestra::mode_input || ( m_mode == audio::orchestra::mode_duplex && m_device[0] != m_device[1])) { - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { AudioDeviceStop(m_private->id[1], &audio::orchestra::api::Core::callbackEvent); } #if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) @@ -914,7 +914,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::closeStream() { m_deviceBuffer = nullptr; } m_mode = audio::orchestra::mode_unknow; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; ATA_VERBOSE("Set state as closed"); return audio::orchestra::error_none; } @@ -925,7 +925,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::startStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { ATA_ERROR("the stream is already running!"); return audio::orchestra::error_warning; } @@ -949,7 +949,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::startStream() { } m_private->drainCounter = 0; m_private->internalDrain = false; - m_state = audio::orchestra::state_running; + m_state = audio::orchestra::state::running; ATA_VERBOSE("Set state as running"); unlock: if (result == noErr) { @@ -962,7 +962,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::stopStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } @@ -989,7 +989,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::stopStream() { goto unlock; } } - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; ATA_VERBOSE("Set state as stopped"); unlock: if (result == noErr) { @@ -1002,7 +1002,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::abortStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } @@ -1026,17 +1026,17 @@ bool audio::orchestra::api::Core::callbackEvent(AudioDeviceID _deviceId, const audio::Time& _inTime, const AudioBufferList *_outBufferList, const audio::Time& _outTime) { - if ( m_state == audio::orchestra::state_stopped - || m_state == audio::orchestra::state_stopping) { + if ( m_state == audio::orchestra::state::stopped + || m_state == audio::orchestra::state::stopping) { return true; } - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("the stream is closed ... this shouldn't happen!"); return false; } // Check if we were draining the stream and signal is finished. if (m_private->drainCounter > 3) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; ATA_VERBOSE("Set state as stopping"); if (m_private->internalDrain == true) { new std::thread(&audio::orchestra::api::Core::coreStopStream, this); @@ -1054,12 +1054,12 @@ bool audio::orchestra::api::Core::callbackEvent(AudioDeviceID _deviceId, std::vector status; if ( m_mode != audio::orchestra::mode_input && m_private->xrun[0] == true) { - status.push_back(audio::orchestra::status_underflow); + status.push_back(audio::orchestra::status::underflow); m_private->xrun[0] = false; } if ( m_mode != audio::orchestra::mode_output && m_private->xrun[1] == true) { - status.push_back(audio::orchestra::status_overflow); + status.push_back(audio::orchestra::status::overflow); m_private->xrun[1] = false; } int32_t cbReturnValue = m_callback(&m_userBuffer[1][0], @@ -1069,7 +1069,7 @@ bool audio::orchestra::api::Core::callbackEvent(AudioDeviceID _deviceId, m_bufferSize, status); if (cbReturnValue == 2) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; ATA_VERBOSE("Set state as stopping"); m_private->drainCounter = 2; abortStream(); diff --git a/audio/orchestra/api/Core.h b/audio/orchestra/api/Core.h index 84e4ad5..3688c5c 100644 --- a/audio/orchestra/api/Core.h +++ b/audio/orchestra/api/Core.h @@ -21,7 +21,7 @@ namespace audio { Core(); virtual ~Core(); const std::string& getCurrentApi() { - return audio::orchestra::type_coreOSX; + return audio::orchestra::typeCoreOSX; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/CoreIos.h b/audio/orchestra/api/CoreIos.h index 82abf1a..67c1635 100644 --- a/audio/orchestra/api/CoreIos.h +++ b/audio/orchestra/api/CoreIos.h @@ -18,7 +18,7 @@ namespace audio { CoreIos(); virtual ~CoreIos(); const std::string& getCurrentApi() { - return audio::orchestra::type_coreIOS; + return audio::orchestra::typeCoreIOS; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/Ds.cpp b/audio/orchestra/api/Ds.cpp index f44e03c..e8b8f94 100644 --- a/audio/orchestra/api/Ds.cpp +++ b/audio/orchestra/api/Ds.cpp @@ -128,7 +128,7 @@ audio::orchestra::api::Ds::~Ds() { if (m_coInitialized) { CoUninitialize(); // balanced call. } - if (m_state != audio::orchestra::state_closed) { + if (m_state != audio::orchestra::state::closed) { closeStream(); } } @@ -748,7 +748,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device, m_private->dsBufferSize[modeToIdTable(_mode)] = dsBufferSize; m_private->dsPointerLeadTime[modeToIdTable(_mode)] = dsPointerLeadTime; m_device[modeToIdTable(_mode)] = _device; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; if ( m_mode == audio::orchestra::mode_output && _mode == audio::orchestra::mode_input) { // We had already set up an output stream. @@ -800,12 +800,12 @@ error: free(m_deviceBuffer); m_deviceBuffer = 0; } - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; return false; } enum audio::orchestra::error audio::orchestra::api::Ds::closeStream() { - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("no open stream to close!"); return audio::orchestra::error_warning; } @@ -842,7 +842,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::closeStream() { m_deviceBuffer = 0; } m_mode = audio::orchestra::mode_unknow; - m_state = audio::orchestra::state_closed; + m_state = audio::orchestra::state::closed; } enum audio::orchestra::error audio::orchestra::api::Ds::startStream() { @@ -851,7 +851,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::startStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_running) { + if (m_state == audio::orchestra::state::running) { ATA_ERROR("the stream is already running!"); return audio::orchestra::error_warning; } @@ -887,7 +887,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::startStream() { m_private->drainCounter = 0; m_private->internalDrain = false; ResetEvent(m_private->condition); - m_state = audio::orchestra::state_running; + m_state = audio::orchestra::state::running; unlock: if (FAILED(result)) { return audio::orchestra::error_systemError; @@ -899,7 +899,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } @@ -912,7 +912,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() { m_private->drainCounter = 2; WaitForSingleObject(m_private->condition, INFINITE); // block until signaled } - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; // Stop the buffer and clear memory LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0]; result = buffer->Stop(); @@ -943,7 +943,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() { LPDIRECTSOUNDCAPTUREBUFFER buffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1]; audioPtr = nullptr; dataLen = 0; - m_state = audio::orchestra::state_stopped; + m_state = audio::orchestra::state::stopped; result = buffer->Stop(); if (FAILED(result)) { ATA_ERROR(getErrorString(result) << ": stopping input buffer!"); @@ -979,7 +979,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::abortStream() { if (verifyStream() != audio::orchestra::error_none) { return audio::orchestra::error_fail; } - if (m_state == audio::orchestra::state_stopped) { + if (m_state == audio::orchestra::state::stopped) { ATA_ERROR("the stream is already stopped!"); return audio::orchestra::error_warning; } @@ -989,17 +989,17 @@ enum audio::orchestra::error audio::orchestra::api::Ds::abortStream() { void audio::orchestra::api::Ds::callbackEvent() { ethread::setName("DS IO-" + m_name); - if (m_state == audio::orchestra::state_stopped || m_state == audio::orchestra::state_stopping) { + if (m_state == audio::orchestra::state::stopped || m_state == audio::orchestra::state_stopping) { Sleep(50); // sleep 50 milliseconds return; } - if (m_state == audio::orchestra::state_closed) { + if (m_state == audio::orchestra::state::closed) { ATA_ERROR("the stream is closed ... this shouldn't happen!"); return; } // Check if we were draining the stream and signal is finished. if (m_private->drainCounter > m_nBuffers + 2) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; if (m_private->internalDrain == false) { SetEvent(m_private->condition); } else { @@ -1014,12 +1014,12 @@ void audio::orchestra::api::Ds::callbackEvent() { std::vector status; if ( m_mode != audio::orchestra::mode_input && m_private->xrun[0] == true) { - status.push_back(audio::orchestra::status_underflow); + status.push_back(audio::orchestra::status::underflow); m_private->xrun[0] = false; } if ( m_mode != audio::orchestra::mode_output && m_private->xrun[1] == true) { - status.push_back(audio::orchestra::status_overflow); + status.push_back(audio::orchestra::status::overflow); m_private->xrun[1] = false; } int32_t cbReturnValue = m_callback(&m_userBuffer[1][0], @@ -1029,7 +1029,7 @@ void audio::orchestra::api::Ds::callbackEvent() { m_bufferSize, status); if (cbReturnValue == 2) { - m_state = audio::orchestra::state_stopping; + m_state = audio::orchestra::state::stopping; m_private->drainCounter = 2; abortStream(); return; diff --git a/audio/orchestra/api/Ds.h b/audio/orchestra/api/Ds.h index 0d43334..2650134 100644 --- a/audio/orchestra/api/Ds.h +++ b/audio/orchestra/api/Ds.h @@ -18,7 +18,7 @@ namespace audio { Ds(); virtual ~Ds(); const std::string& getCurrentApi() { - return audio::orchestra::type_ds; + return audio::orchestra::typeDs; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/Dummy.h b/audio/orchestra/api/Dummy.h index 390d314..c02c37f 100644 --- a/audio/orchestra/api/Dummy.h +++ b/audio/orchestra/api/Dummy.h @@ -19,7 +19,7 @@ namespace audio { public: Dummy(); const std::string& getCurrentApi() { - return audio::orchestra::type_dummy; + return audio::orchestra::typeDummy; } uint32_t getDeviceCount(); audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device); diff --git a/audio/orchestra/api/Jack.cpp b/audio/orchestra/api/Jack.cpp index ff48f8c..a113047 100644 --- a/audio/orchestra/api/Jack.cpp +++ b/audio/orchestra/api/Jack.cpp @@ -16,9 +16,6 @@ #include #include