[DEV] update of external of elog and ethread

This commit is contained in:
Edouard DUPIN 2016-03-08 21:29:34 +01:00
parent b5bdb4e2db
commit e7511a0b92
17 changed files with 58 additions and 58 deletions

View File

@ -58,7 +58,7 @@ audio::orchestra::Api::~Api() {
enum audio::orchestra::error audio::orchestra::Api::startStream() {
ATA_VERBOSE("Start Stream");
m_startTime = audio::Time::now();
m_duration = std11::chrono::microseconds(0);
m_duration = std::chrono::microseconds(0);
return audio::orchestra::error_none;
}

View File

@ -27,7 +27,7 @@ namespace audio {
* @param _nbChunk The number of chunk of input or output chunk in the buffer (same size).
* @param _status List of error that occured in the laps of time.
*/
typedef std11::function<int32_t (const void* _inputBuffer,
typedef std::function<int32_t (const void* _inputBuffer,
const audio::Time& _timeInput,
void* _outputBuffer,
const audio::Time& _timeOutput,
@ -85,7 +85,7 @@ namespace audio {
}
protected:
mutable std11::mutex m_mutex;
mutable std::mutex m_mutex;
audio::orchestra::AirTAudioCallback m_callback;
uint32_t m_device[2]; // Playback and record, respectively.
enum audio::orchestra::mode m_mode; // audio::orchestra::mode_output, audio::orchestra::mode_input, or audio::orchestra::mode_duplex.
@ -166,7 +166,7 @@ namespace audio {
uint32_t _firstChannel);
public:
virtual bool isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api) {
virtual bool isMasterOf(std::shared_ptr<audio::orchestra::Api> _api) {
return false;
};
};

View File

@ -13,7 +13,7 @@
#include <audio/orchestra/Interface.h>
#include <audio/orchestra/debug.h>
#include <etk/stdTools.h>
#include <etk/thread/tools.h>
#include <ethread/tools.h>
#include <limits.h>
#include <audio/orchestra/api/Alsa.h>
extern "C" {
@ -41,9 +41,9 @@ namespace audio {
public:
snd_pcm_t *handle;
bool xrun[2];
std11::condition_variable runnable_cv;
std::condition_variable runnable_cv;
bool runnable;
std11::thread* thread;
std::thread* thread;
bool threadRunning;
bool mmapInterface; //!< enable or disable mmap mode...
enum timestampMode timeMode; //!< the timestamp of the flow came from the harware.
@ -804,13 +804,13 @@ bool audio::orchestra::api::Alsa::openName(const std::string& _deviceName,
// Setup callback thread.
m_private->threadRunning = true;
ATA_INFO("create thread ...");
m_private->thread = new std11::thread(&audio::orchestra::api::Alsa::alsaCallbackEvent, this);
m_private->thread = new std::thread(&audio::orchestra::api::Alsa::alsaCallbackEvent, this);
if (m_private->thread == nullptr) {
m_private->threadRunning = false;
ATA_ERROR("creating callback thread!");
goto error;
}
etk::thread::setPriority(*m_private->thread, -6);
ethread::setPriority(*m_private->thread, -6);
return true;
error:
if (m_private->handle) {
@ -876,7 +876,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::startStream() {
ATA_ERROR("the stream is already running!");
return audio::orchestra::error_warning;
}
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
int32_t result = 0;
snd_pcm_state_t state;
if (m_private->handle == nullptr) {
@ -910,7 +910,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::stopStream() {
return audio::orchestra::error_warning;
}
m_state = audio::orchestra::state_stopped;
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
int32_t result = 0;
if (m_mode == audio::orchestra::mode_output) {
result = snd_pcm_drain(m_private->handle);
@ -937,7 +937,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::abortStream() {
return audio::orchestra::error_warning;
}
m_state = audio::orchestra::state_stopped;
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
int32_t result = 0;
result = snd_pcm_drop(m_private->handle);
if (result < 0) {
@ -980,7 +980,7 @@ 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) {
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
while (!m_private->runnable) {
m_private->runnable_cv.wait(lck);
}
@ -988,7 +988,7 @@ void audio::orchestra::api::Alsa::callbackEvent() {
return;
}
}
etk::thread::setName("Alsa IO-" + m_name);
ethread::setName("Alsa IO-" + m_name);
//Wait data with poll
std::vector<struct pollfd> ufds;
signed short *ptr;
@ -1121,7 +1121,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleRead() {
// !!! goto unlock;
}
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
// Setup parameters.
if (m_doConvertBuffer[1]) {
buffer = m_deviceBuffer;
@ -1257,7 +1257,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() {
abortStream();
return;
}
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
// Setup parameters and do buffer conversion if necessary.
if (m_doConvertBuffer[0]) {
buffer = m_deviceBuffer;
@ -1364,7 +1364,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() {
return;
}
{
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
// Setup parameters and do buffer conversion if necessary.
if (m_doConvertBuffer[0]) {
buffer = m_deviceBuffer;
@ -1472,7 +1472,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() {
goto unlock;
}
{
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
// Setup parameters.
if (m_doConvertBuffer[1]) {
buffer = m_deviceBuffer;
@ -1566,8 +1566,8 @@ unlock:
}
bool audio::orchestra::api::Alsa::isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api) {
std11::shared_ptr<audio::orchestra::api::Alsa> slave = std::dynamic_pointer_cast<audio::orchestra::api::Alsa>(_api);
bool audio::orchestra::api::Alsa::isMasterOf(std::shared_ptr<audio::orchestra::Api> _api) {
std::shared_ptr<audio::orchestra::api::Alsa> slave = std::dynamic_pointer_cast<audio::orchestra::api::Alsa>(_api);
if (slave == nullptr) {
ATA_ERROR("NULL ptr API (not ALSA ...)");
return false;

View File

@ -50,7 +50,7 @@ namespace audio {
private:
static void alsaCallbackEvent(void* _userData);
private:
std11::shared_ptr<AlsaPrivate> m_private;
std::shared_ptr<AlsaPrivate> m_private;
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool open(uint32_t _device,
@ -72,7 +72,7 @@ namespace audio {
const audio::orchestra::StreamOptions& _options);
virtual audio::Time getStreamTime();
public:
bool isMasterOf(std11::shared_ptr<audio::orchestra::Api> _api);
bool isMasterOf(std::shared_ptr<audio::orchestra::Api> _api);
};
}
}

View File

@ -148,7 +148,7 @@ bool audio::orchestra::api::Android::open(uint32_t _device,
m_userFormat = _format;
m_nUserChannels[modeToIdTable(m_mode)] = _channels;
m_uid = audio::orchestra::api::android::open(_device, m_mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, std11::static_pointer_cast<audio::orchestra::api::Android>(shared_from_this()));
m_uid = audio::orchestra::api::android::open(_device, m_mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, std::static_pointer_cast<audio::orchestra::api::Android>(shared_from_this()));
if (m_uid < 0) {
ret = false;
} else {

View File

@ -253,7 +253,7 @@ class AndroidOrchestraContext {
} else {
info.input = true;
}
std11::shared_ptr<const ejson::Array> list = doc.getArray("sample-rate");
std::shared_ptr<const ejson::Array> list = doc.getArray("sample-rate");
if (list != nullptr) {
for (size_t iii=0; iii<list->size(); ++iii) {
info.sampleRates.push_back(int32_t(list->getNumberValue(iii, 48000)));
@ -276,7 +276,7 @@ class AndroidOrchestraContext {
return info;
}
private:
std::vector<std11::weak_ptr<audio::orchestra::api::Android> > m_instanceList; // list of connected handle ...
std::vector<std::weak_ptr<audio::orchestra::api::Android> > m_instanceList; // list of connected handle ...
//AndroidAudioCallback m_audioCallBack;
//void* m_audioCallBackUserData;
public:
@ -288,7 +288,7 @@ class AndroidOrchestraContext {
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance) {
std::shared_ptr<audio::orchestra::api::Android> _instance) {
ATA_DEBUG("C->java : audio open device");
int status;
if(!java_attach_current_thread(&status)) {
@ -422,7 +422,7 @@ int32_t audio::orchestra::api::android::open(uint32_t _device,
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance) {
std::shared_ptr<audio::orchestra::api::Android> _instance) {
if (s_localContext == nullptr) {
return -1;
}

View File

@ -29,7 +29,7 @@ namespace audio {
audio::format _format,
uint32_t *_bufferSize,
const audio::orchestra::StreamOptions& _options,
std11::shared_ptr<audio::orchestra::api::Android> _instance);
std::shared_ptr<audio::orchestra::api::Android> _instance);
enum audio::orchestra::error closeStream(int32_t _id);
enum audio::orchestra::error startStream(int32_t _id);
enum audio::orchestra::error stopStream(int32_t _id);

View File

@ -17,7 +17,7 @@
#include <audio/orchestra/Interface.h>
#include <audio/orchestra/debug.h>
#include <thread>
#include <etk/thread/tools.h>
#include <ethread/tools.h>
#include <audio/orchestra/api/Core.h>
std::shared_ptr<audio::orchestra::Api> audio::orchestra::api::Core::create() {
@ -40,7 +40,7 @@ namespace audio {
uint32_t nStreams[2]; // number of streams to use
bool xrun[2];
char *deviceBuffer;
std11::condition_variable condition;
std::condition_variable condition;
int32_t drainCounter; // Tracks callback counts when draining
bool internalDrain; // Indicates if stop is initiated from callback or not.
CorePrivate() :
@ -970,7 +970,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::stopStream() {
if ( m_mode == audio::orchestra::mode_output
|| m_mode == audio::orchestra::mode_duplex) {
if (m_private->drainCounter == 0) {
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
m_private->drainCounter = 2;
m_private->condition.wait(lck);
}
@ -1016,7 +1016,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::abortStream() {
// callbackEvent() function probably should return before the AudioDeviceStop()
// function is called.
void audio::orchestra::api::Core::coreStopStream(void *_userData) {
etk::thread::setName("CoreAudio_stopStream");
ethread::setName("CoreAudio_stopStream");
audio::orchestra::api::Core* myClass = reinterpret_cast<audio::orchestra::api::Core*>(_userData);
myClass->stopStream();
}
@ -1039,7 +1039,7 @@ bool audio::orchestra::api::Core::callbackEvent(AudioDeviceID _deviceId,
m_state = audio::orchestra::state_stopping;
ATA_VERBOSE("Set state as stopping");
if (m_private->internalDrain == true) {
new std11::thread(&audio::orchestra::api::Core::coreStopStream, this);
new std::thread(&audio::orchestra::api::Core::coreStopStream, this);
} else {
// external call to stopStream()
m_private->condition.notify_one();

View File

@ -47,7 +47,7 @@ namespace audio {
int32_t _nbChunk,
const audio::Time& _time);
public:
std11::shared_ptr<CoreIosPrivate> m_private;
std::shared_ptr<CoreIosPrivate> m_private;
};
}
}

View File

@ -9,7 +9,7 @@
#if defined(ORCHESTRA_BUILD_DS)
#include <audio/orchestra/Interface.h>
#include <audio/orchestra/debug.h>
#include <etk/thread/tools.h>
#include <ethread/tools.h>
#include <audio/orchestra/api/Ds.h>
#undef __class__
@ -75,7 +75,7 @@ namespace audio {
namespace api {
class DsPrivate {
public:
std11::shared_ptr<std11::thread> thread;
std::shared_ptr<std::thread> thread;
bool threadRunning;
uint32_t drainCounter; // Tracks callback counts when draining
bool internalDrain; // Indicates if stop is initiated from callback or not.
@ -765,7 +765,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
// Setup the callback thread.
if (m_private->threadRunning == false) {
m_private->threadRunning = true;
std11::shared_ptr<std11::thread> tmpThread(new std11::thread(&audio::orchestra::api::Ds::dsCallbackEvent, this));
std::shared_ptr<std::thread> tmpThread(new std::thread(&audio::orchestra::api::Ds::dsCallbackEvent, this));
m_private->thread = std::move(tmpThread);
if (m_private->thread == nullptr) {
ATA_ERROR("error creating callback thread!");
@ -988,7 +988,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::abortStream() {
}
void audio::orchestra::api::Ds::callbackEvent() {
etk::thread::setName("DS IO-" + m_name);
ethread::setName("DS IO-" + m_name);
if (m_state == audio::orchestra::state_stopped || m_state == audio::orchestra::state_stopping) {
Sleep(50); // sleep 50 milliseconds
return;

View File

@ -34,7 +34,7 @@ namespace audio {
void callbackEvent();
private:
static void dsCallbackEvent(void *_userData);
std11::shared_ptr<DsPrivate> m_private;
std::shared_ptr<DsPrivate> m_private;
bool m_coInitialized;
bool m_buffersRolling;
long m_duplexPrerollBytes;

View File

@ -13,7 +13,7 @@
#include <audio/orchestra/Interface.h>
#include <audio/orchestra/debug.h>
#include <string.h>
#include <etk/thread/tools.h>
#include <ethread/tools.h>
#include <audio/orchestra/api/Jack.h>
#undef __class__
@ -68,7 +68,7 @@ namespace audio {
jack_port_t **ports[2];
std::string deviceName[2];
bool xrun[2];
std11::condition_variable condition;
std::condition_variable condition;
int32_t drainCounter; // Tracks callback counts when draining
bool internalDrain; // Indicates if stop is initiated from callback or not.
@ -231,7 +231,7 @@ int32_t audio::orchestra::api::Jack::jackCallbackHandler(jack_nframes_t _nframes
// it this way because the jackShutdown() function must return before
// the jack_deactivate() function (in closeStream()) will return.
void audio::orchestra::api::Jack::jackCloseStream(void* _userData) {
etk::thread::setName("Jack_closeStream");
ethread::setName("Jack_closeStream");
audio::orchestra::api::Jack* myClass = reinterpret_cast<audio::orchestra::api::Jack*>(_userData);
myClass->closeStream();
}
@ -246,7 +246,7 @@ void audio::orchestra::api::Jack::jackShutdown(void* _userData) {
if (myClass->isStreamRunning() == false) {
return;
}
new std11::thread(&audio::orchestra::api::Jack::jackCloseStream, _userData);
new std::thread(&audio::orchestra::api::Jack::jackCloseStream, _userData);
ATA_ERROR("The Jack server is shutting down this client ... stream stopped and closed!!");
}
@ -600,7 +600,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::stopStream() {
|| m_mode == audio::orchestra::mode_duplex) {
if (m_private->drainCounter == 0) {
m_private->drainCounter = 2;
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
m_private->condition.wait(lck);
}
}
@ -627,7 +627,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::abortStream() {
// callbackEvent() function must return before the jack_deactivate()
// function will return.
static void jackStopStream(void* _userData) {
etk::thread::setName("Jack_stopStream");
ethread::setName("Jack_stopStream");
audio::orchestra::api::Jack* myClass = reinterpret_cast<audio::orchestra::api::Jack*>(_userData);
myClass->stopStream();
}
@ -649,7 +649,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
if (m_private->drainCounter > 3) {
m_state = audio::orchestra::state_stopping;
if (m_private->internalDrain == true) {
new std11::thread(jackStopStream, this);
new std::thread(jackStopStream, this);
} else {
m_private->condition.notify_one();
}
@ -676,7 +676,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
if (cbReturnValue == 2) {
m_state = audio::orchestra::state_stopping;
m_private->drainCounter = 2;
new std11::thread(jackStopStream, this);
new std::thread(jackStopStream, this);
return true;
}
else if (cbReturnValue == 1) {

View File

@ -40,7 +40,7 @@ namespace audio {
static void jackShutdown(void* _userData);
static int32_t jackCallbackHandler(jack_nframes_t _nframes, void* _userData);
private:
std11::shared_ptr<JackPrivate> m_private;
std::shared_ptr<JackPrivate> m_private;
bool open(uint32_t _device,
audio::orchestra::mode _mode,
uint32_t _channels,

View File

@ -15,7 +15,7 @@
#include <pulse/error.h>
#include <pulse/simple.h>
#include <cstdio>
#include <etk/thread/tools.h>
#include <ethread/tools.h>
#include <audio/orchestra/api/PulseDeviceList.h>
#include <audio/orchestra/api/Pulse.h>
@ -56,9 +56,9 @@ namespace audio {
class PulsePrivate {
public:
pa_simple* handle;
std11::shared_ptr<std11::thread> thread;
std::shared_ptr<std::thread> thread;
bool threadRunning;
std11::condition_variable runnable_cv;
std::condition_variable runnable_cv;
bool runnable;
PulsePrivate() :
handle(0),
@ -105,7 +105,7 @@ static void pulseaudio_callback(void* _userData) {
}
void audio::orchestra::api::Pulse::callbackEvent() {
etk::thread::setName("Pulse IO-" + m_name);
ethread::setName("Pulse IO-" + m_name);
while (m_private->threadRunning == true) {
callbackEventOneCycle();
}
@ -134,7 +134,7 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
void audio::orchestra::api::Pulse::callbackEventOneCycle() {
if (m_state == audio::orchestra::state_stopped) {
std11::unique_lock<std11::mutex> lck(m_mutex);
std::unique_lock<std::mutex> lck(m_mutex);
while (!m_private->runnable) {
m_private->runnable_cv.wait(lck);
}
@ -396,7 +396,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
}
if (m_private->threadRunning == false) {
m_private->threadRunning = true;
m_private->thread = std11::make_shared<std11::thread>(&pulseaudio_callback, this);
m_private->thread = std::make_shared<std::thread>(&pulseaudio_callback, this);
if (m_private->thread == nullptr) {
ATA_ERROR("error creating thread.");
goto error;

View File

@ -33,7 +33,7 @@ namespace audio {
void callbackEventOneCycle();
void callbackEvent();
private:
std11::shared_ptr<PulsePrivate> m_private;
std::shared_ptr<PulsePrivate> m_private;
std::vector<audio::orchestra::DeviceInfo> m_devices;
void saveDeviceInfo();
bool open(uint32_t _device,

View File

@ -8,6 +8,6 @@
#include <audio/orchestra/debug.h>
int32_t audio::orchestra::getLogId() {
static int32_t g_val = etk::log::registerInstance("audio-orchestra");
static int32_t g_val = elog::registerInstance("audio-orchestra");
return g_val;
}

View File

@ -6,14 +6,14 @@
*/
#pragma once
#include <etk/log.h>
#include <elog/log.h>
namespace audio {
namespace orchestra {
int32_t getLogId();
}
}
#define ATA_BASE(info,data) TK_LOG_BASE(audio::orchestra::getLogId(),info,data)
#define ATA_BASE(info,data) ELOG_BASE(audio::orchestra::getLogId(),info,data)
#define ATA_PRINT(data) ATA_BASE(-1, data)
#define ATA_CRITICAL(data) ATA_BASE(1, data)