[DEV] remove STL

This commit is contained in:
Edouard DUPIN 2017-09-07 23:38:26 +02:00
parent a4ba319ffc
commit dfc867db87
8 changed files with 31 additions and 31 deletions

View File

@ -32,7 +32,7 @@ namespace audio {
* @param _nbChunk The number of chunk of input or output chunk in the buffer (same size). * @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. * @param _status List of error that occured in the laps of time.
*/ */
typedef std::function<int32_t (const void* _inputBuffer, typedef etk::Function<int32_t (const void* _inputBuffer,
const audio::Time& _timeInput, const audio::Time& _timeInput,
void* _outputBuffer, void* _outputBuffer,
const audio::Time& _timeOutput, const audio::Time& _timeOutput,
@ -90,7 +90,7 @@ namespace audio {
} }
protected: protected:
mutable std::mutex m_mutex; mutable ethread::Mutex m_mutex;
audio::orchestra::AirTAudioCallback m_callback; audio::orchestra::AirTAudioCallback m_callback;
uint32_t m_device[2]; // Playback and record, respectively. 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. enum audio::orchestra::mode m_mode; // audio::orchestra::mode_output, audio::orchestra::mode_input, or audio::orchestra::mode_duplex.

View File

@ -41,7 +41,7 @@ namespace audio {
bool xrun[2]; bool xrun[2];
std::condition_variable runnable_cv; std::condition_variable runnable_cv;
bool runnable; bool runnable;
std::thread* thread; ethread::Thread* thread;
bool threadRunning; bool threadRunning;
bool mmapInterface; //!< enable or disable mmap mode... bool mmapInterface; //!< enable or disable mmap mode...
enum timestampMode timeMode; //!< the timestamp of the flow came from the harware. enum timestampMode timeMode; //!< the timestamp of the flow came from the harware.
@ -803,7 +803,7 @@ bool audio::orchestra::api::Alsa::openName(const etk::String& _deviceName,
// Setup callback thread. // Setup callback thread.
m_private->threadRunning = true; m_private->threadRunning = true;
ATA_INFO("create thread ..."); ATA_INFO("create thread ...");
m_private->thread = new std::thread(&audio::orchestra::api::Alsa::alsaCallbackEvent, this); m_private->thread = new ethread::Thread(&audio::orchestra::api::Alsa::alsaCallbackEvent, this);
if (m_private->thread == nullptr) { if (m_private->thread == nullptr) {
m_private->threadRunning = false; m_private->threadRunning = false;
ATA_ERROR("creating callback thread!"); ATA_ERROR("creating callback thread!");
@ -875,7 +875,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::startStream() {
ATA_ERROR("the stream is already running!"); ATA_ERROR("the stream is already running!");
return audio::orchestra::error_warning; return audio::orchestra::error_warning;
} }
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
int32_t result = 0; int32_t result = 0;
snd_pcm_state_t state; snd_pcm_state_t state;
if (m_private->handle == nullptr) { if (m_private->handle == nullptr) {
@ -909,7 +909,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::stopStream() {
return audio::orchestra::error_warning; 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); std::unique_lock<ethread::Mutex> lck(m_mutex);
int32_t result = 0; int32_t result = 0;
if (m_mode == audio::orchestra::mode_output) { if (m_mode == audio::orchestra::mode_output) {
result = snd_pcm_drain(m_private->handle); result = snd_pcm_drain(m_private->handle);
@ -936,7 +936,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::abortStream() {
return audio::orchestra::error_warning; 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); std::unique_lock<ethread::Mutex> lck(m_mutex);
int32_t result = 0; int32_t result = 0;
result = snd_pcm_drop(m_private->handle); result = snd_pcm_drop(m_private->handle);
if (result < 0) { if (result < 0) {
@ -979,7 +979,7 @@ static int32_t wait_for_poll(snd_pcm_t* _handle, struct pollfd* _ufds, unsigned
void audio::orchestra::api::Alsa::callbackEvent() { void audio::orchestra::api::Alsa::callbackEvent() {
// Lock while the system is not started ... // 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); std::unique_lock<ethread::Mutex> lck(m_mutex);
while (!m_private->runnable) { while (!m_private->runnable) {
m_private->runnable_cv.wait(lck); m_private->runnable_cv.wait(lck);
} }
@ -1121,7 +1121,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleRead() {
// !!! goto unlock; // !!! goto unlock;
} }
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
// Setup parameters. // Setup parameters.
if (m_doConvertBuffer[1]) { if (m_doConvertBuffer[1]) {
buffer = m_deviceBuffer; buffer = m_deviceBuffer;
@ -1258,7 +1258,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() {
abortStream(); abortStream();
return; return;
} }
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
// Setup parameters and do buffer conversion if necessary. // Setup parameters and do buffer conversion if necessary.
if (m_doConvertBuffer[0]) { if (m_doConvertBuffer[0]) {
buffer = m_deviceBuffer; buffer = m_deviceBuffer;
@ -1365,7 +1365,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() {
return; return;
} }
{ {
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
// Setup parameters and do buffer conversion if necessary. // Setup parameters and do buffer conversion if necessary.
if (m_doConvertBuffer[0]) { if (m_doConvertBuffer[0]) {
buffer = m_deviceBuffer; buffer = m_deviceBuffer;
@ -1474,7 +1474,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() {
goto unlock; goto unlock;
} }
{ {
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
// Setup parameters. // Setup parameters.
if (m_doConvertBuffer[1]) { if (m_doConvertBuffer[1]) {
buffer = m_deviceBuffer; buffer = m_deviceBuffer;

View File

@ -6,7 +6,7 @@
#include <jni.h> #include <jni.h>
#include <pthread.h> #include <pthread.h>
#include <mutex> #include <ethread/Mutex.hpp>
#include <audio/orchestra/debug.hpp> #include <audio/orchestra/debug.hpp>
#include <audio/orchestra/error.hpp> #include <audio/orchestra/error.hpp>
#include <audio/orchestra/api/AndroidNativeInterface.hpp> #include <audio/orchestra/api/AndroidNativeInterface.hpp>
@ -461,7 +461,7 @@ extern "C" {
void Java_org_musicdsp_orchestra_OrchestraNative_NNsetJavaManager(JNIEnv* _env, void Java_org_musicdsp_orchestra_OrchestraNative_NNsetJavaManager(JNIEnv* _env,
jclass _classBase, jclass _classBase,
jobject _objCallback) { jobject _objCallback) {
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM()); std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
ATA_INFO("*******************************************"); ATA_INFO("*******************************************");
ATA_INFO("** Creating Orchestra context **"); ATA_INFO("** Creating Orchestra context **");
ATA_INFO("*******************************************"); ATA_INFO("*******************************************");
@ -477,7 +477,7 @@ extern "C" {
} }
void Java_org_musicdsp_orchestra_OrchestraNative_NNsetJavaManagerRemove(JNIEnv* _env, jclass _cls) { void Java_org_musicdsp_orchestra_OrchestraNative_NNsetJavaManagerRemove(JNIEnv* _env, jclass _cls) {
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM()); std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
ATA_INFO("*******************************************"); ATA_INFO("*******************************************");
ATA_INFO("** remove Orchestra Pointer **"); ATA_INFO("** remove Orchestra Pointer **");
ATA_INFO("*******************************************"); ATA_INFO("*******************************************");
@ -495,7 +495,7 @@ extern "C" {
jint _id, jint _id,
jshortArray _location, jshortArray _location,
jint _nbChunk) { jint _nbChunk) {
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM()); std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
if (s_localContext == nullptr) { if (s_localContext == nullptr) {
ATA_ERROR("Call audio with no more Low level interface"); ATA_ERROR("Call audio with no more Low level interface");
return; return;
@ -518,7 +518,7 @@ extern "C" {
jint _id, jint _id,
jshortArray _location, jshortArray _location,
jint _nbChunk) { jint _nbChunk) {
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM()); std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
if (s_localContext == nullptr) { if (s_localContext == nullptr) {
ATA_ERROR("Call audio with no more Low level interface"); ATA_ERROR("Call audio with no more Low level interface");
return; return;

View File

@ -16,7 +16,7 @@
#include <audio/orchestra/Interface.hpp> #include <audio/orchestra/Interface.hpp>
#include <audio/orchestra/debug.hpp> #include <audio/orchestra/debug.hpp>
#include <thread> #include <ethread/Thread.hpp>
#include <ethread/tools.hpp> #include <ethread/tools.hpp>
#include <audio/orchestra/api/Core.hpp> #include <audio/orchestra/api/Core.hpp>
@ -967,7 +967,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::stopStream() {
if ( m_mode == audio::orchestra::mode_output if ( m_mode == audio::orchestra::mode_output
|| m_mode == audio::orchestra::mode_duplex) { || m_mode == audio::orchestra::mode_duplex) {
if (m_private->drainCounter == 0) { if (m_private->drainCounter == 0) {
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
m_private->drainCounter = 2; m_private->drainCounter = 2;
m_private->condition.wait(lck); m_private->condition.wait(lck);
} }
@ -1036,7 +1036,7 @@ bool audio::orchestra::api::Core::callbackEvent(AudioDeviceID _deviceId,
m_state = audio::orchestra::state::stopping; m_state = audio::orchestra::state::stopping;
ATA_VERBOSE("Set state as stopping"); ATA_VERBOSE("Set state as stopping");
if (m_private->internalDrain == true) { if (m_private->internalDrain == true) {
new std::thread(&audio::orchestra::api::Core::coreStopStream, this); new ethread::Thread(&audio::orchestra::api::Core::coreStopStream, this);
} else { } else {
// external call to stopStream() // external call to stopStream()
m_private->condition.notify_one(); m_private->condition.notify_one();

View File

@ -72,7 +72,7 @@ namespace audio {
namespace api { namespace api {
class DsPrivate { class DsPrivate {
public: public:
ememory::SharedPtr<std::thread> thread; ememory::SharedPtr<ethread::Thread> thread;
bool threadRunning; bool threadRunning;
uint32_t drainCounter; // Tracks callback counts when draining uint32_t drainCounter; // Tracks callback counts when draining
bool internalDrain; // Indicates if stop is initiated from callback or not. bool internalDrain; // Indicates if stop is initiated from callback or not.
@ -762,7 +762,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
// Setup the callback thread. // Setup the callback thread.
if (m_private->threadRunning == false) { if (m_private->threadRunning == false) {
m_private->threadRunning = true; m_private->threadRunning = true;
ememory::SharedPtr<std::thread> tmpThread(new std::thread(&audio::orchestra::api::Ds::dsCallbackEvent, this)); ememory::SharedPtr<ethread::Thread> tmpThread(new std::thread(&audio::orchestra::api::Ds::dsCallbackEvent, this));
m_private->thread = etk::move(tmpThread); m_private->thread = etk::move(tmpThread);
if (m_private->thread == nullptr) { if (m_private->thread == nullptr) {
ATA_ERROR("error creating callback thread!"); ATA_ERROR("error creating callback thread!");

View File

@ -243,7 +243,7 @@ void audio::orchestra::api::Jack::jackShutdown(void* _userData) {
if (myClass->isStreamRunning() == false) { if (myClass->isStreamRunning() == false) {
return; return;
} }
new std::thread(&audio::orchestra::api::Jack::jackCloseStream, _userData); new ethread::Thread(&audio::orchestra::api::Jack::jackCloseStream, _userData);
ATA_ERROR("The Jack server is shutting down this client ... stream stopped and closed!!"); ATA_ERROR("The Jack server is shutting down this client ... stream stopped and closed!!");
} }
@ -597,7 +597,7 @@ enum audio::orchestra::error audio::orchestra::api::Jack::stopStream() {
|| m_mode == audio::orchestra::mode_duplex) { || m_mode == audio::orchestra::mode_duplex) {
if (m_private->drainCounter == 0) { if (m_private->drainCounter == 0) {
m_private->drainCounter = 2; m_private->drainCounter = 2;
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<ethread::Mutex> lck(m_mutex);
m_private->condition.wait(lck); m_private->condition.wait(lck);
} }
} }
@ -646,7 +646,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
if (m_private->drainCounter > 3) { if (m_private->drainCounter > 3) {
m_state = audio::orchestra::state::stopping; m_state = audio::orchestra::state::stopping;
if (m_private->internalDrain == true) { if (m_private->internalDrain == true) {
new std::thread(jackStopStream, this); new ethread::Thread(jackStopStream, this);
} else { } else {
m_private->condition.notify_one(); m_private->condition.notify_one();
} }
@ -673,7 +673,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
if (cbReturnValue == 2) { if (cbReturnValue == 2) {
m_state = audio::orchestra::state::stopping; m_state = audio::orchestra::state::stopping;
m_private->drainCounter = 2; m_private->drainCounter = 2;
new std::thread(jackStopStream, this); new ethread::Thread(jackStopStream, this);
return true; return true;
} }
else if (cbReturnValue == 1) { else if (cbReturnValue == 1) {

View File

@ -53,7 +53,7 @@ namespace audio {
class PulsePrivate { class PulsePrivate {
public: public:
pa_simple* handle; pa_simple* handle;
ememory::SharedPtr<std::thread> thread; ememory::SharedPtr<ethread::Thread> thread;
bool threadRunning; bool threadRunning;
std::condition_variable runnable_cv; std::condition_variable runnable_cv;
bool runnable; bool runnable;
@ -131,7 +131,7 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
void audio::orchestra::api::Pulse::callbackEventOneCycle() { 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); std::unique_lock<ethread::Mutex> lck(m_mutex);
while (!m_private->runnable) { while (!m_private->runnable) {
m_private->runnable_cv.wait(lck); m_private->runnable_cv.wait(lck);
} }
@ -393,7 +393,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
} }
if (m_private->threadRunning == false) { if (m_private->threadRunning == false) {
m_private->threadRunning = true; m_private->threadRunning = true;
m_private->thread = ememory::makeShared<std::thread>(&pulseaudio_callback, this); m_private->thread = ememory::makeShared<ethread::Thread>(&pulseaudio_callback, this);
if (m_private->thread == nullptr) { if (m_private->thread == nullptr) {
ATA_ERROR("error creating thread."); ATA_ERROR("error creating thread.");
goto error; goto error;

View File

@ -6,9 +6,9 @@
*/ */
#pragma once #pragma once
#include <thread> #include <ethread/Thread.hpp>
#include <condition_variable> #include <condition_variable>
#include <mutex> #include <ethread/Mutex.hpp>
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <ememory/memory.hpp> #include <ememory/memory.hpp>