[DEV] remove STL
This commit is contained in:
parent
a4ba319ffc
commit
dfc867db87
@ -32,7 +32,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 std::function<int32_t (const void* _inputBuffer,
|
||||
typedef etk::Function<int32_t (const void* _inputBuffer,
|
||||
const audio::Time& _timeInput,
|
||||
void* _outputBuffer,
|
||||
const audio::Time& _timeOutput,
|
||||
@ -90,7 +90,7 @@ namespace audio {
|
||||
}
|
||||
|
||||
protected:
|
||||
mutable std::mutex m_mutex;
|
||||
mutable ethread::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.
|
||||
|
@ -41,7 +41,7 @@ namespace audio {
|
||||
bool xrun[2];
|
||||
std::condition_variable runnable_cv;
|
||||
bool runnable;
|
||||
std::thread* thread;
|
||||
ethread::Thread* thread;
|
||||
bool threadRunning;
|
||||
bool mmapInterface; //!< enable or disable mmap mode...
|
||||
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.
|
||||
m_private->threadRunning = true;
|
||||
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) {
|
||||
m_private->threadRunning = false;
|
||||
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!");
|
||||
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;
|
||||
snd_pcm_state_t state;
|
||||
if (m_private->handle == nullptr) {
|
||||
@ -909,7 +909,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::stopStream() {
|
||||
return audio::orchestra::error_warning;
|
||||
}
|
||||
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;
|
||||
if (m_mode == audio::orchestra::mode_output) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
result = snd_pcm_drop(m_private->handle);
|
||||
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() {
|
||||
// Lock while the system is not started ...
|
||||
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) {
|
||||
m_private->runnable_cv.wait(lck);
|
||||
}
|
||||
@ -1121,7 +1121,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleRead() {
|
||||
// !!! goto unlock;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lck(m_mutex);
|
||||
std::unique_lock<ethread::Mutex> lck(m_mutex);
|
||||
// Setup parameters.
|
||||
if (m_doConvertBuffer[1]) {
|
||||
buffer = m_deviceBuffer;
|
||||
@ -1258,7 +1258,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() {
|
||||
abortStream();
|
||||
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.
|
||||
if (m_doConvertBuffer[0]) {
|
||||
buffer = m_deviceBuffer;
|
||||
@ -1365,7 +1365,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() {
|
||||
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.
|
||||
if (m_doConvertBuffer[0]) {
|
||||
buffer = m_deviceBuffer;
|
||||
@ -1474,7 +1474,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPRead() {
|
||||
goto unlock;
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(m_mutex);
|
||||
std::unique_lock<ethread::Mutex> lck(m_mutex);
|
||||
// Setup parameters.
|
||||
if (m_doConvertBuffer[1]) {
|
||||
buffer = m_deviceBuffer;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
#include <pthread.h>
|
||||
#include <mutex>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <audio/orchestra/debug.hpp>
|
||||
#include <audio/orchestra/error.hpp>
|
||||
#include <audio/orchestra/api/AndroidNativeInterface.hpp>
|
||||
@ -461,7 +461,7 @@ extern "C" {
|
||||
void Java_org_musicdsp_orchestra_OrchestraNative_NNsetJavaManager(JNIEnv* _env,
|
||||
jclass _classBase,
|
||||
jobject _objCallback) {
|
||||
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
ATA_INFO("*******************************************");
|
||||
ATA_INFO("** Creating Orchestra context **");
|
||||
ATA_INFO("*******************************************");
|
||||
@ -477,7 +477,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
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("** remove Orchestra Pointer **");
|
||||
ATA_INFO("*******************************************");
|
||||
@ -495,7 +495,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jshortArray _location,
|
||||
jint _nbChunk) {
|
||||
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
if (s_localContext == nullptr) {
|
||||
ATA_ERROR("Call audio with no more Low level interface");
|
||||
return;
|
||||
@ -518,7 +518,7 @@ extern "C" {
|
||||
jint _id,
|
||||
jshortArray _location,
|
||||
jint _nbChunk) {
|
||||
std::unique_lock<std::mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
std::unique_lock<ethread::Mutex> lock(jvm_basics::getMutexJavaVM());
|
||||
if (s_localContext == nullptr) {
|
||||
ATA_ERROR("Call audio with no more Low level interface");
|
||||
return;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <audio/orchestra/Interface.hpp>
|
||||
#include <audio/orchestra/debug.hpp>
|
||||
#include <thread>
|
||||
#include <ethread/Thread.hpp>
|
||||
#include <ethread/tools.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
|
||||
|| m_mode == audio::orchestra::mode_duplex) {
|
||||
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->condition.wait(lck);
|
||||
}
|
||||
@ -1036,7 +1036,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 std::thread(&audio::orchestra::api::Core::coreStopStream, this);
|
||||
new ethread::Thread(&audio::orchestra::api::Core::coreStopStream, this);
|
||||
} else {
|
||||
// external call to stopStream()
|
||||
m_private->condition.notify_one();
|
||||
|
@ -72,7 +72,7 @@ namespace audio {
|
||||
namespace api {
|
||||
class DsPrivate {
|
||||
public:
|
||||
ememory::SharedPtr<std::thread> thread;
|
||||
ememory::SharedPtr<ethread::Thread> thread;
|
||||
bool threadRunning;
|
||||
uint32_t drainCounter; // Tracks callback counts when draining
|
||||
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.
|
||||
if (m_private->threadRunning == false) {
|
||||
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);
|
||||
if (m_private->thread == nullptr) {
|
||||
ATA_ERROR("error creating callback thread!");
|
||||
|
@ -243,7 +243,7 @@ void audio::orchestra::api::Jack::jackShutdown(void* _userData) {
|
||||
if (myClass->isStreamRunning() == false) {
|
||||
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!!");
|
||||
}
|
||||
|
||||
@ -597,7 +597,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;
|
||||
std::unique_lock<std::mutex> lck(m_mutex);
|
||||
std::unique_lock<ethread::Mutex> lck(m_mutex);
|
||||
m_private->condition.wait(lck);
|
||||
}
|
||||
}
|
||||
@ -646,7 +646,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 std::thread(jackStopStream, this);
|
||||
new ethread::Thread(jackStopStream, this);
|
||||
} else {
|
||||
m_private->condition.notify_one();
|
||||
}
|
||||
@ -673,7 +673,7 @@ bool audio::orchestra::api::Jack::callbackEvent(uint64_t _nframes) {
|
||||
if (cbReturnValue == 2) {
|
||||
m_state = audio::orchestra::state::stopping;
|
||||
m_private->drainCounter = 2;
|
||||
new std::thread(jackStopStream, this);
|
||||
new ethread::Thread(jackStopStream, this);
|
||||
return true;
|
||||
}
|
||||
else if (cbReturnValue == 1) {
|
||||
|
@ -53,7 +53,7 @@ namespace audio {
|
||||
class PulsePrivate {
|
||||
public:
|
||||
pa_simple* handle;
|
||||
ememory::SharedPtr<std::thread> thread;
|
||||
ememory::SharedPtr<ethread::Thread> thread;
|
||||
bool threadRunning;
|
||||
std::condition_variable runnable_cv;
|
||||
bool runnable;
|
||||
@ -131,7 +131,7 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
|
||||
|
||||
void audio::orchestra::api::Pulse::callbackEventOneCycle() {
|
||||
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) {
|
||||
m_private->runnable_cv.wait(lck);
|
||||
}
|
||||
@ -393,7 +393,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
|
||||
}
|
||||
if (m_private->threadRunning == false) {
|
||||
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) {
|
||||
ATA_ERROR("error creating thread.");
|
||||
goto error;
|
||||
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
#include <ethread/Thread.hpp>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <ememory/memory.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user