[DEV] update the change on 'enum' to 'enum class'

This commit is contained in:
2016-04-29 23:16:07 +02:00
parent f4f1ee888b
commit bc78a1858a
24 changed files with 184 additions and 190 deletions

View File

@@ -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<std::mutex> 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<std::mutex> 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<std::mutex> 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<enum audio::orchestra::status> 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<enum audio::orchestra::status> 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<enum audio::orchestra::status> 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<enum audio::orchestra::status> 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<audio::orchestra::A
ATA_ERROR("NULL ptr API (not ALSA ...)");
return false;
}
if (m_state == audio::orchestra::state_running) {
if (m_state == audio::orchestra::state::running) {
ATA_ERROR("The MASTER stream is already running! ==> 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;
}

View File

@@ -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:

View File

@@ -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);

View File

@@ -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::vector<enum audio::orchestra::status status;
if (m_mode != audio::orchestra::mode_input && asioXRun == true) {
status.push_back(audio::orchestra::status_underflow);
status.push_back(audio::orchestra::status::underflow);
asioXRun = false;
}
if (m_mode != audio::orchestra::mode_output && asioXRun == true) {
status.push_back(audio::orchestra::status_underflow;
status.push_back(audio::orchestra::status::underflow;
asioXRun = false;
}
int32_t cbReturnValue = info->callback(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,

View File

@@ -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);

View File

@@ -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<enum audio::orchestra::status> 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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<audio::orchestra::status> 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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -16,9 +16,6 @@
#include <ethread/tools.h>
#include <audio/orchestra/api/Jack.h>
#undef __class__
#define __class__ "api::Jack"
std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Jack::create() {
return std::shared_ptr<audio::orchestra::Api>(new audio::orchestra::api::Jack());
}
@@ -92,7 +89,7 @@ audio::orchestra::api::Jack::Jack() :
}
audio::orchestra::api::Jack::~Jack() {
if (m_state != audio::orchestra::state_closed) {
if (m_state != audio::orchestra::state::closed) {
closeStream();
}
}
@@ -426,7 +423,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
}
m_device[modeToIdTable(_mode)] = _device;
m_channelOffset[modeToIdTable(_mode)] = _firstChannel;
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 the stream for output.
@@ -486,12 +483,12 @@ error:
}
enum audio::orchestra::error audio::orchestra::api::Jack::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_private != nullptr) {
if (m_state == audio::orchestra::state_running) {
if (m_state == audio::orchestra::state::running) {
jack_deactivate(m_private->client);
}
jack_client_close(m_private->client);
@@ -512,7 +509,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::closeStream() {
m_deviceBuffer = nullptr;
}
m_mode = audio::orchestra::mode_unknow;
m_state = audio::orchestra::state_closed;
m_state = audio::orchestra::state::closed;
return audio::orchestra::error_none;
}
@@ -522,7 +519,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::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;
}
@@ -580,7 +577,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::startStream() {
}
m_private->drainCounter = 0;
m_private->internalDrain = false;
m_state = audio::orchestra::state_running;
m_state = audio::orchestra::state::running;
unlock:
if (result == 0) {
return audio::orchestra::error_none;
@@ -592,7 +589,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::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;
}
@@ -605,7 +602,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::stopStream() {
}
}
jack_deactivate(m_private->client);
m_state = audio::orchestra::state_stopped;
m_state = audio::orchestra::state::stopped;
return audio::orchestra::error_none;
}
@@ -613,7 +610,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::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;
}
@@ -633,11 +630,11 @@ static void jackStopStream(void* _userData) {
}
bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
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;
}
@@ -647,7 +644,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
}
// 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;
if (m_private->internalDrain == true) {
new std::thread(jackStopStream, this);
} else {
@@ -660,11 +657,11 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
audio::Time streamTime = getStreamTime();
std::vector<enum audio::orchestra::status> 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],
@@ -674,7 +671,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
m_bufferSize,
status);
if (cbReturnValue == 2) {
m_state = audio::orchestra::state_stopping;
m_state = audio::orchestra::state::stopping;
m_private->drainCounter = 2;
new std::thread(jackStopStream, this);
return true;

View File

@@ -20,7 +20,7 @@ namespace audio {
Jack();
virtual ~Jack();
const std::string& getCurrentApi() {
return audio::orchestra::type_jack;
return audio::orchestra::typeJack;
}
uint32_t getDeviceCount();
audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device);

View File

@@ -76,7 +76,7 @@ audio::orchestra::api::Pulse::Pulse() :
}
audio::orchestra::api::Pulse::~Pulse() {
if (m_state != audio::orchestra::state_closed) {
if (m_state != audio::orchestra::state::closed) {
closeStream();
}
}
@@ -114,7 +114,7 @@ void audio::orchestra::api::Pulse::callbackEvent() {
enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
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();;
}
@@ -127,23 +127,23 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
m_private->handle = nullptr;
m_userBuffer[0].clear();
m_userBuffer[1].clear();
m_state = audio::orchestra::state_closed;
m_state = audio::orchestra::state::closed;
m_mode = audio::orchestra::mode_unknow;
return audio::orchestra::error_none;
}
void audio::orchestra::api::Pulse::callbackEventOneCycle() {
if (m_state == audio::orchestra::state_stopped) {
if (m_state == audio::orchestra::state::stopped) {
std::unique_lock<std::mutex> 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) {
m_mutex.unlock();
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;
}
@@ -162,7 +162,7 @@ void audio::orchestra::api::Pulse::callbackEventOneCycle() {
m_mutex.lock();
void *pulse_in = m_doConvertBuffer[audio::orchestra::modeToIdTable(audio::orchestra::mode_input)] ? m_deviceBuffer : &m_userBuffer[audio::orchestra::modeToIdTable(audio::orchestra::mode_input)][0];
void *pulse_out = m_doConvertBuffer[audio::orchestra::modeToIdTable(audio::orchestra::mode_output)] ? m_deviceBuffer : &m_userBuffer[audio::orchestra::modeToIdTable(audio::orchestra::mode_output)][0];
if (m_state != audio::orchestra::state_running) {
if (m_state != audio::orchestra::state::running) {
goto unlock;
}
int32_t pa_error;
@@ -210,16 +210,16 @@ unlock:
enum audio::orchestra::error audio::orchestra::api::Pulse::startStream() {
// TODO : Check return ...
audio::orchestra::Api::startStream();
if (m_state == audio::orchestra::state_closed) {
if (m_state == audio::orchestra::state::closed) {
ATA_ERROR("the stream is not open!");
return audio::orchestra::error_invalidUse;
}
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;
}
m_mutex.lock();
m_state = audio::orchestra::state_running;
m_state = audio::orchestra::state::running;
m_private->runnable = true;
m_private->runnable_cv.notify_one();
m_mutex.unlock();
@@ -227,15 +227,15 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::startStream() {
}
enum audio::orchestra::error audio::orchestra::api::Pulse::stopStream() {
if (m_state == audio::orchestra::state_closed) {
if (m_state == audio::orchestra::state::closed) {
ATA_ERROR("the stream is not open!");
return audio::orchestra::error_invalidUse;
}
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;
m_mutex.lock();
if ( m_private != nullptr
&& m_private->handle != nullptr
@@ -247,21 +247,21 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::stopStream() {
return audio::orchestra::error_systemError;
}
}
m_state = audio::orchestra::state_stopped;
m_state = audio::orchestra::state::stopped;
m_mutex.unlock();
return audio::orchestra::error_none;
}
enum audio::orchestra::error audio::orchestra::api::Pulse::abortStream() {
if (m_state == audio::orchestra::state_closed) {
if (m_state == audio::orchestra::state::closed) {
ATA_ERROR("the stream is not open!");
return audio::orchestra::error_invalidUse;
}
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;
m_mutex.lock();
if ( m_private != nullptr
&& m_private->handle != nullptr
@@ -273,7 +273,7 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::abortStream() {
return audio::orchestra::error_systemError;
}
}
m_state = audio::orchestra::state_stopped;
m_state = audio::orchestra::state::stopped;
m_mutex.unlock();
return audio::orchestra::error_none;
}
@@ -402,7 +402,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
goto error;
}
}
m_state = audio::orchestra::state_stopped;
m_state = audio::orchestra::state::stopped;
return true;
error:
for (int32_t iii=0; iii<2; ++iii) {

View File

@@ -18,7 +18,7 @@ namespace audio {
Pulse();
virtual ~Pulse();
const std::string& getCurrentApi() {
return audio::orchestra::type_pulse;
return audio::orchestra::typePulse;
}
uint32_t getDeviceCount();
audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device);