[DEV] update sharedPtr
This commit is contained in:
parent
8b86ac13ec
commit
cf2a769087
@ -53,7 +53,7 @@ audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanR
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
||||
#else
|
||||
m_thread = std::make_shared<std::thread>(&audio::ess::LoadedFile::threadCall, this);
|
||||
m_thread = ememory::makeShared<std::thread>(&audio::ess::LoadedFile::threadCall, this);
|
||||
if (m_thread == nullptr) {
|
||||
EWOLSA_ERROR("Can not create thread ...");
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <thread>
|
||||
#include <ememory/memory.h>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
@ -21,7 +22,7 @@ namespace audio {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_t m_thread;
|
||||
#else
|
||||
std::shared_ptr<std::thread> m_thread;
|
||||
ememory::SharedPtr<std::thread> m_thread;
|
||||
#endif
|
||||
public:
|
||||
LoadedFile(const std::string& _fileName, int8_t _nbChanRequested=1);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <audio/ess/decWav.h>
|
||||
#include <math.h>
|
||||
|
||||
audio::ess::Effects::Effects(const std::shared_ptr<audio::river::Manager>& _manager) :
|
||||
audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||
m_manager(_manager) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
//Set stereo output:
|
||||
@ -51,7 +51,7 @@ audio::ess::Effects::~Effects() {
|
||||
}
|
||||
|
||||
|
||||
static bool playData(const std::shared_ptr<audio::ess::LoadedFile>& _file, int32_t& _position, int16_t* _bufferInterlace, int32_t _nbSample) {
|
||||
static bool playData(const ememory::SharedPtr<audio::ess::LoadedFile>& _file, int32_t& _position, int16_t* _bufferInterlace, int32_t _nbSample) {
|
||||
if ( _file == nullptr
|
||||
|| _file->m_data.size() == 0) {
|
||||
return true;
|
||||
@ -59,7 +59,7 @@ static bool playData(const std::shared_ptr<audio::ess::LoadedFile>& _file, int32
|
||||
int32_t processTimeMax = std::min(_nbSample, _file->m_nbSamples - _position);
|
||||
processTimeMax = std::max(0, processTimeMax);
|
||||
int16_t * pointer = _bufferInterlace;
|
||||
int16_t * newData = &_file->m_data[_position];
|
||||
const int16_t * newData = &_file->m_data[_position];
|
||||
//EWOLSA_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " playTime=" <<m_playTime << " nbCannels=" << nbChannels);
|
||||
for (int32_t iii=0; iii<processTimeMax; iii++) {
|
||||
int32_t tmppp = int32_t(*_bufferInterlace) + int32_t(*newData);
|
||||
@ -99,7 +99,7 @@ void audio::ess::Effects::onDataNeeded(void* _data,
|
||||
|
||||
void audio::ess::Effects::load(const std::string& _file, const std::string& _name) {
|
||||
// load the file:
|
||||
std::shared_ptr<audio::ess::LoadedFile> tmp = std::make_shared<audio::ess::LoadedFile>(_file, 2);
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> tmp = ememory::makeShared<audio::ess::LoadedFile>(_file, 2);
|
||||
if (tmp == nullptr) {
|
||||
EWOLSA_ERROR("can not load audio Effects = " << _file);
|
||||
return;
|
||||
@ -113,7 +113,7 @@ void audio::ess::Effects::load(const std::string& _file, const std::string& _nam
|
||||
}
|
||||
}
|
||||
if (-1 <= id) {
|
||||
m_list.push_back(std::pair<std::string,std::shared_ptr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
} else {
|
||||
m_list[id].second = tmp;
|
||||
}
|
||||
@ -126,7 +126,7 @@ int32_t audio::ess::Effects::getId(const std::string& _name) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
m_list.push_back(std::pair<std::string,std::shared_ptr<audio::ess::LoadedFile>>(_name,nullptr));
|
||||
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,nullptr));
|
||||
EWOLSA_WARNING("Can not find element name : '" << _name << "' added it ... (empty) ");
|
||||
return m_list.size()-1;
|
||||
}
|
||||
@ -138,7 +138,7 @@ void audio::ess::Effects::play(int32_t _id, const vec3& _pos) {
|
||||
EWOLSA_ERROR(" Can not play element audio with ID=" << _id << " out of [0.." << m_list.size() << "[");
|
||||
return;
|
||||
}
|
||||
m_playing.push_back(std::pair<std::shared_ptr<audio::ess::LoadedFile>, int32_t>(m_list[_id].second, 0));
|
||||
m_playing.push_back(std::pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>(m_list[_id].second, 0));
|
||||
}
|
||||
|
||||
void audio::ess::Effects::play(const std::string& _name, const vec3& _pos) {
|
||||
|
@ -17,10 +17,10 @@ namespace audio {
|
||||
class Effects {
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
std::shared_ptr<audio::river::Manager> m_manager;
|
||||
std::shared_ptr<audio::river::Interface> m_interface;
|
||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||
public:
|
||||
Effects(const std::shared_ptr<audio::river::Manager>& _manager);
|
||||
Effects(const ememory::SharedPtr<audio::river::Manager>& _manager);
|
||||
~Effects();
|
||||
private:
|
||||
void onDataNeeded(void* _data,
|
||||
@ -29,8 +29,8 @@ namespace audio {
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map);
|
||||
std::vector<std::pair<std::shared_ptr<audio::ess::LoadedFile>, int32_t>> m_playing; //!< current music read
|
||||
std::vector<std::pair<std::string, std::shared_ptr<audio::ess::LoadedFile>>> m_list; //!< list of all effect loaded
|
||||
std::vector<std::pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>> m_playing; //!< current music read
|
||||
std::vector<std::pair<std::string, ememory::SharedPtr<audio::ess::LoadedFile>>> m_list; //!< list of all effect loaded
|
||||
public:
|
||||
void load(const std::string& _file, const std::string& _name);
|
||||
int32_t getId(const std::string& _name);
|
||||
|
@ -13,14 +13,14 @@
|
||||
#include <audio/ess/debug.h>
|
||||
#include <ejson/ejson.h>
|
||||
|
||||
std::shared_ptr<audio::river::Manager> g_audioManager;
|
||||
std::shared_ptr<audio::ess::Effects> g_effects;
|
||||
std::shared_ptr<audio::ess::Music> g_music;
|
||||
ememory::SharedPtr<audio::river::Manager> g_audioManager;
|
||||
ememory::SharedPtr<audio::ess::Effects> g_effects;
|
||||
ememory::SharedPtr<audio::ess::Music> g_music;
|
||||
|
||||
void audio::ess::init() {
|
||||
g_audioManager = audio::river::Manager::create("ewol-sound-set");
|
||||
g_effects = std::make_shared<audio::ess::Effects>(g_audioManager);
|
||||
g_music = std::make_shared<audio::ess::Music>(g_audioManager);
|
||||
g_effects = ememory::makeShared<audio::ess::Effects>(g_audioManager);
|
||||
g_music = ememory::makeShared<audio::ess::Music>(g_audioManager);
|
||||
}
|
||||
|
||||
void audio::ess::unInit() {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <audio/ess/LoadedFile.h>
|
||||
#include <math.h>
|
||||
|
||||
audio::ess::Music::Music(const std::shared_ptr<audio::river::Manager>& _manager) :
|
||||
audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||
m_manager(_manager),
|
||||
m_position(0) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
@ -97,13 +97,13 @@ void audio::ess::Music::load(const std::string& _file, const std::string& _name)
|
||||
if (it != m_list.end()) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<audio::ess::LoadedFile> tmp = std::make_shared<audio::ess::LoadedFile>(_file, 2);
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> tmp = ememory::makeShared<audio::ess::LoadedFile>(_file, 2);
|
||||
if (tmp == nullptr) {
|
||||
EWOLSA_ERROR("can not load audio Music = " << _file);
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_list.insert(std::pair<std::string,std::shared_ptr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
m_list.insert(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
}
|
||||
|
||||
void audio::ess::Music::play(const std::string& _name) {
|
||||
|
@ -18,10 +18,10 @@ namespace audio {
|
||||
class Music {
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
std::shared_ptr<audio::river::Manager> m_manager;
|
||||
std::shared_ptr<audio::river::Interface> m_interface;
|
||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||
public:
|
||||
Music(const std::shared_ptr<audio::river::Manager>& _manager);
|
||||
Music(const ememory::SharedPtr<audio::river::Manager>& _manager);
|
||||
~Music();
|
||||
private:
|
||||
void onDataNeeded(void* _data,
|
||||
@ -30,10 +30,10 @@ namespace audio {
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map);
|
||||
std::shared_ptr<audio::ess::LoadedFile> m_current; //!< current music read
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> m_current; //!< current music read
|
||||
int32_t m_position; //!< current position of music read
|
||||
std::map<std::string, std::shared_ptr<audio::ess::LoadedFile> > m_list; //!< list of all music loaded
|
||||
std::shared_ptr<audio::ess::LoadedFile> m_next; //!< next music to read
|
||||
std::map<std::string, ememory::SharedPtr<audio::ess::LoadedFile> > m_list; //!< list of all music loaded
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> m_next; //!< next music to read
|
||||
public:
|
||||
void load(const std::string& _file, const std::string& _name);
|
||||
void play(const std::string& _name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user