[DEV] remove STL
This commit is contained in:
parent
f55fa25f04
commit
cf6baea92f
@ -53,7 +53,7 @@ audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanR
|
|||||||
#if defined(__TARGET_OS__Android)
|
#if defined(__TARGET_OS__Android)
|
||||||
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
||||||
#else
|
#else
|
||||||
m_thread = ememory::makeShared<std::thread>(&audio::ess::LoadedFile::threadCall, this);
|
m_thread = ememory::makeShared<ethread::Thread>(&audio::ess::LoadedFile::threadCall, this);
|
||||||
if (m_thread == nullptr) {
|
if (m_thread == nullptr) {
|
||||||
EWOLSA_ERROR("Can not create thread ...");
|
EWOLSA_ERROR("Can not create thread ...");
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <etk/types.hpp>
|
#include <etk/types.hpp>
|
||||||
#include <thread>
|
#include <ethread/Thread.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
@ -22,7 +22,7 @@ namespace audio {
|
|||||||
#if defined(__TARGET_OS__Android)
|
#if defined(__TARGET_OS__Android)
|
||||||
pthread_t m_thread;
|
pthread_t m_thread;
|
||||||
#else
|
#else
|
||||||
ememory::SharedPtr<std::thread> m_thread;
|
ememory::SharedPtr<ethread::Thread> m_thread;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||||
m_manager(_manager) {
|
m_manager(_manager) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
etk::Vector<audio::channel> channelMap;
|
etk::Vector<audio::channel> channelMap;
|
||||||
channelMap.pushBack(audio::channel_frontCenter);
|
channelMap.pushBack(audio::channel_frontCenter);
|
||||||
@ -84,7 +84,7 @@ void audio::ess::Effects::onDataNeeded(void* _data,
|
|||||||
if (_format != audio::format_float) {
|
if (_format != audio::format_float) {
|
||||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
auto it = m_playing.begin();
|
auto it = m_playing.begin();
|
||||||
while (it != m_playing.end()) {
|
while (it != m_playing.end()) {
|
||||||
bool ret = playData((*it).first, (*it).second, static_cast<float*>(_data), _nbChunk);
|
bool ret = playData((*it).first, (*it).second, static_cast<float*>(_data), _nbChunk);
|
||||||
@ -103,7 +103,7 @@ void audio::ess::Effects::load(const etk::String& _file, const etk::String& _nam
|
|||||||
EWOLSA_ERROR("can not load audio Effects = " << _file);
|
EWOLSA_ERROR("can not load audio Effects = " << _file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
int32_t id = -1;
|
int32_t id = -1;
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
if (m_list[iii].first == _name) {
|
if (m_list[iii].first == _name) {
|
||||||
@ -119,7 +119,7 @@ void audio::ess::Effects::load(const etk::String& _file, const etk::String& _nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t audio::ess::Effects::getId(const etk::String& _name) {
|
int32_t audio::ess::Effects::getId(const etk::String& _name) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||||
if (m_list[iii].first == _name) {
|
if (m_list[iii].first == _name) {
|
||||||
return iii;
|
return iii;
|
||||||
@ -131,7 +131,7 @@ int32_t audio::ess::Effects::getId(const etk::String& _name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::ess::Effects::play(int32_t _id, const vec3& _pos) {
|
void audio::ess::Effects::play(int32_t _id, const vec3& _pos) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
if ( _id < 0
|
if ( _id < 0
|
||||||
|| _id >= m_list.size()) {
|
|| _id >= m_list.size()) {
|
||||||
EWOLSA_ERROR(" Can not play element audio with ID=" << _id << " out of [0.." << m_list.size() << "[");
|
EWOLSA_ERROR(" Can not play element audio with ID=" << _id << " out of [0.." << m_list.size() << "[");
|
||||||
@ -148,12 +148,12 @@ void audio::ess::Effects::stop() {
|
|||||||
if (m_playing.size() == 0) {
|
if (m_playing.size() == 0) {
|
||||||
EWOLSA_INFO("No current audio is playing");
|
EWOLSA_INFO("No current audio is playing");
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
m_playing.clear();
|
m_playing.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio::ess::Effects::clear() {
|
void audio::ess::Effects::clear() {
|
||||||
stop();
|
stop();
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
m_list.clear();
|
m_list.clear();
|
||||||
}
|
}
|
@ -10,13 +10,13 @@
|
|||||||
#include <audio/river/Interface.hpp>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <audio/river/Manager.hpp>
|
#include <audio/river/Manager.hpp>
|
||||||
#include <audio/ess/LoadedFile.hpp>
|
#include <audio/ess/LoadedFile.hpp>
|
||||||
#include <mutex>
|
#include <ethread/Mutex.hpp>
|
||||||
|
|
||||||
namespace audio {
|
namespace audio {
|
||||||
namespace ess {
|
namespace ess {
|
||||||
class Effects {
|
class Effects {
|
||||||
private:
|
private:
|
||||||
mutable std::mutex m_mutex;
|
mutable ethread::Mutex m_mutex;
|
||||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
public:
|
public:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||||
m_manager(_manager),
|
m_manager(_manager),
|
||||||
m_position(0) {
|
m_position(0) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
//Set stereo output:
|
//Set stereo output:
|
||||||
etk::Vector<audio::channel> channelMap;
|
etk::Vector<audio::channel> channelMap;
|
||||||
channelMap.pushBack(audio::channel_frontLeft);
|
channelMap.pushBack(audio::channel_frontLeft);
|
||||||
@ -63,7 +63,7 @@ void audio::ess::Music::onDataNeeded(void* _data,
|
|||||||
if (_format != audio::format_float) {
|
if (_format != audio::format_float) {
|
||||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
if (m_current != m_next) {
|
if (m_current != m_next) {
|
||||||
EWOLSA_INFO("change track " << (m_current==nullptr?-1:m_current->getUId()) << " ==> " << (m_next==nullptr?-1:m_next->getUId()));
|
EWOLSA_INFO("change track " << (m_current==nullptr?-1:m_current->getUId()) << " ==> " << (m_next==nullptr?-1:m_next->getUId()));
|
||||||
m_current = m_next;
|
m_current = m_next;
|
||||||
@ -102,7 +102,7 @@ void audio::ess::Music::load(const etk::String& _file, const etk::String& _name)
|
|||||||
EWOLSA_ERROR("can not load audio Music = " << _file);
|
EWOLSA_ERROR("can not load audio Music = " << _file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
m_list.insert(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
m_list.insert(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ void audio::ess::Music::play(const etk::String& _name) {
|
|||||||
}
|
}
|
||||||
// in all case we stop the current playing music ...
|
// in all case we stop the current playing music ...
|
||||||
stop();
|
stop();
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
m_next = it->second;
|
m_next = it->second;
|
||||||
EWOLSA_INFO("Playing track " << (m_current==nullptr?-1:m_current->getUId()) << " request next : " << m_next->getUId());
|
EWOLSA_INFO("Playing track " << (m_current==nullptr?-1:m_current->getUId()) << " request next : " << m_next->getUId());
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ void audio::ess::Music::stop() {
|
|||||||
if (m_current == nullptr) {
|
if (m_current == nullptr) {
|
||||||
EWOLSA_INFO("No current audio is playing");
|
EWOLSA_INFO("No current audio is playing");
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<ethread::Mutex> lock(m_mutex);
|
||||||
m_current.reset();
|
m_current.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <audio/river/Interface.hpp>
|
#include <audio/river/Interface.hpp>
|
||||||
#include <audio/river/Manager.hpp>
|
#include <audio/river/Manager.hpp>
|
||||||
#include <audio/ess/LoadedFile.hpp>
|
#include <audio/ess/LoadedFile.hpp>
|
||||||
#include <mutex>
|
#include <ethread/Mutex.hpp>
|
||||||
#include <etk/Map.hpp>
|
#include <etk/Map.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ namespace audio {
|
|||||||
namespace ess {
|
namespace ess {
|
||||||
class Music {
|
class Music {
|
||||||
private:
|
private:
|
||||||
mutable std::mutex m_mutex;
|
mutable ethread::Mutex m_mutex;
|
||||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user