[DEV] update new ETK
This commit is contained in:
parent
6069305dd7
commit
457dfe6a06
@ -12,17 +12,6 @@
|
||||
#include <audio/ess/decWav.hpp>
|
||||
#include <audio/ess/decOgg.hpp>
|
||||
|
||||
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* audio::ess::LoadedFile::threadCallback(void* _userData) {
|
||||
audio::ess::LoadedFile* threadHandle = static_cast<audio::ess::LoadedFile*>(_userData);
|
||||
if (threadHandle != nullptr) {
|
||||
threadHandle->threadCall();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void audio::ess::LoadedFile::threadCall() {
|
||||
decode();
|
||||
}
|
||||
@ -35,9 +24,6 @@ void audio::ess::LoadedFile::decode() {
|
||||
}
|
||||
|
||||
audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested) :
|
||||
#if !defined(__TARGET_OS__Android)
|
||||
m_thread(nullptr),
|
||||
#endif
|
||||
m_file(_fileName),
|
||||
m_nbSamples(0),
|
||||
m_nbChanRequested(_nbChanRequested),
|
||||
@ -50,15 +36,11 @@ audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanR
|
||||
} else if (etk::end_with(tmpName, ".ogg") == true) {
|
||||
#if 1
|
||||
EWOLSA_INFO("create thread");
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
||||
#else
|
||||
m_thread = ememory::makeShared<ethread::Thread>(&audio::ess::LoadedFile::threadCall, this);
|
||||
m_thread = ememory::makeShared<ethread::Thread>([&](){decode();}, "audioDecoding");
|
||||
if (m_thread == nullptr) {
|
||||
EWOLSA_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ethread::sleepMilliSeconds((1));
|
||||
#else
|
||||
decode();
|
||||
@ -70,15 +52,10 @@ audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanR
|
||||
}
|
||||
|
||||
audio::ess::LoadedFile::~LoadedFile() {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* ret = nullptr;
|
||||
int val = pthread_join(m_thread, &ret);
|
||||
#else
|
||||
if (m_thread != nullptr) {
|
||||
m_thread->join();
|
||||
}
|
||||
m_thread.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,11 +19,7 @@ namespace audio {
|
||||
return m_uid;
|
||||
}
|
||||
private:
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_t m_thread;
|
||||
#else
|
||||
ememory::SharedPtr<ethread::Thread> m_thread;
|
||||
#endif
|
||||
public:
|
||||
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
||||
~LoadedFile();
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <audio/ess/decOgg.hpp>
|
||||
#include <tremor/ivorbiscodec.h>
|
||||
#include <tremor/ivorbisfile.h>
|
||||
#include <memory>
|
||||
#include <ememory/UniquePtr.hpp>
|
||||
|
||||
|
||||
static size_t LocalReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) {
|
||||
@ -57,7 +57,7 @@ etk::Vector<float> audio::ess::ogg::loadAudioFile(const etk::String& _filename,
|
||||
localCloseFunc,
|
||||
localTellFunc
|
||||
};
|
||||
std::unique_ptr<etk::FSNode> fileAccess = std::unique_ptr<etk::FSNode>(new etk::FSNode(_filename));
|
||||
ememory::UniquePtr<etk::FSNode> fileAccess = ememory::UniquePtr<etk::FSNode>(new etk::FSNode(_filename));
|
||||
// Start loading the XML :
|
||||
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
||||
if (false == fileAccess->exist()) {
|
||||
|
@ -29,14 +29,14 @@ audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _m
|
||||
m_interface->setName("audio::ess::Effects");
|
||||
m_interface->addVolumeGroup("EFFECT");
|
||||
// set callback mode ...
|
||||
m_interface->setOutputCallback(std::bind(&audio::ess::Effects::onDataNeeded,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interface->setOutputCallback([=] (void* _data,
|
||||
const audio::Time& _playTime,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
audio::ess::Effects::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||
});
|
||||
m_interface->start();
|
||||
}
|
||||
|
||||
@ -84,6 +84,7 @@ void audio::ess::Effects::onDataNeeded(void* _data,
|
||||
if (_format != audio::format_float) {
|
||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||
}
|
||||
EWOLSA_VERBOSE(" get data Effect: "<< _nbChunk);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_playing.begin();
|
||||
while (it != m_playing.end()) {
|
||||
|
@ -31,14 +31,14 @@ audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manag
|
||||
m_interface->setName("audio::ess::music");
|
||||
m_interface->addVolumeGroup("MUSIC");
|
||||
// set callback mode ...
|
||||
m_interface->setOutputCallback(std::bind(&audio::ess::Music::onDataNeeded,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interface->setOutputCallback([=] (void* _data,
|
||||
const audio::Time& _playTime,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
audio::ess::Music::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||
});
|
||||
m_interface->start();
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ void audio::ess::Music::onDataNeeded(void* _data,
|
||||
if (_format != audio::format_float) {
|
||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||
}
|
||||
EWOLSA_VERBOSE(" get data Music: "<< _nbChunk);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
if (m_current != m_next) {
|
||||
EWOLSA_INFO("change track " << (m_current==nullptr?-1:m_current->getUId()) << " ==> " << (m_next==nullptr?-1:m_next->getUId()));
|
||||
@ -103,7 +104,7 @@ void audio::ess::Music::load(const etk::String& _file, const etk::String& _name)
|
||||
return;
|
||||
}
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_list.insert(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
m_list.add(_name, tmp);
|
||||
}
|
||||
|
||||
void audio::ess::Music::play(const etk::String& _name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user