[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/decWav.hpp>
|
||||||
#include <audio/ess/decOgg.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() {
|
void audio::ess::LoadedFile::threadCall() {
|
||||||
decode();
|
decode();
|
||||||
}
|
}
|
||||||
@ -35,9 +24,6 @@ void audio::ess::LoadedFile::decode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested) :
|
audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested) :
|
||||||
#if !defined(__TARGET_OS__Android)
|
|
||||||
m_thread(nullptr),
|
|
||||||
#endif
|
|
||||||
m_file(_fileName),
|
m_file(_fileName),
|
||||||
m_nbSamples(0),
|
m_nbSamples(0),
|
||||||
m_nbChanRequested(_nbChanRequested),
|
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) {
|
} else if (etk::end_with(tmpName, ".ogg") == true) {
|
||||||
#if 1
|
#if 1
|
||||||
EWOLSA_INFO("create thread");
|
EWOLSA_INFO("create thread");
|
||||||
#if defined(__TARGET_OS__Android)
|
m_thread = ememory::makeShared<ethread::Thread>([&](){decode();}, "audioDecoding");
|
||||||
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
|
||||||
#else
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ethread::sleepMilliSeconds((1));
|
ethread::sleepMilliSeconds((1));
|
||||||
#else
|
#else
|
||||||
decode();
|
decode();
|
||||||
@ -70,15 +52,10 @@ audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanR
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio::ess::LoadedFile::~LoadedFile() {
|
audio::ess::LoadedFile::~LoadedFile() {
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
void* ret = nullptr;
|
|
||||||
int val = pthread_join(m_thread, &ret);
|
|
||||||
#else
|
|
||||||
if (m_thread != nullptr) {
|
if (m_thread != nullptr) {
|
||||||
m_thread->join();
|
m_thread->join();
|
||||||
}
|
}
|
||||||
m_thread.reset();
|
m_thread.reset();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,11 +19,7 @@ namespace audio {
|
|||||||
return m_uid;
|
return m_uid;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
pthread_t m_thread;
|
|
||||||
#else
|
|
||||||
ememory::SharedPtr<ethread::Thread> m_thread;
|
ememory::SharedPtr<ethread::Thread> m_thread;
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
||||||
~LoadedFile();
|
~LoadedFile();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <audio/ess/decOgg.hpp>
|
#include <audio/ess/decOgg.hpp>
|
||||||
#include <tremor/ivorbiscodec.h>
|
#include <tremor/ivorbiscodec.h>
|
||||||
#include <tremor/ivorbisfile.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) {
|
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,
|
localCloseFunc,
|
||||||
localTellFunc
|
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 :
|
// Start loading the XML :
|
||||||
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
||||||
if (false == fileAccess->exist()) {
|
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->setName("audio::ess::Effects");
|
||||||
m_interface->addVolumeGroup("EFFECT");
|
m_interface->addVolumeGroup("EFFECT");
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setOutputCallback(std::bind(&audio::ess::Effects::onDataNeeded,
|
m_interface->setOutputCallback([=] (void* _data,
|
||||||
this,
|
const audio::Time& _playTime,
|
||||||
std::placeholders::_1,
|
const size_t& _nbChunk,
|
||||||
std::placeholders::_2,
|
enum audio::format _format,
|
||||||
std::placeholders::_3,
|
uint32_t _sampleRate,
|
||||||
std::placeholders::_4,
|
const etk::Vector<audio::channel>& _map) {
|
||||||
std::placeholders::_5,
|
audio::ess::Effects::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||||
std::placeholders::_6));
|
});
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +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)");
|
||||||
}
|
}
|
||||||
|
EWOLSA_VERBOSE(" get data Effect: "<< _nbChunk);
|
||||||
ethread::UniqueLock lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
auto it = m_playing.begin();
|
auto it = m_playing.begin();
|
||||||
while (it != m_playing.end()) {
|
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->setName("audio::ess::music");
|
||||||
m_interface->addVolumeGroup("MUSIC");
|
m_interface->addVolumeGroup("MUSIC");
|
||||||
// set callback mode ...
|
// set callback mode ...
|
||||||
m_interface->setOutputCallback(std::bind(&audio::ess::Music::onDataNeeded,
|
m_interface->setOutputCallback([=] (void* _data,
|
||||||
this,
|
const audio::Time& _playTime,
|
||||||
std::placeholders::_1,
|
const size_t& _nbChunk,
|
||||||
std::placeholders::_2,
|
enum audio::format _format,
|
||||||
std::placeholders::_3,
|
uint32_t _sampleRate,
|
||||||
std::placeholders::_4,
|
const etk::Vector<audio::channel>& _map) {
|
||||||
std::placeholders::_5,
|
audio::ess::Music::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||||
std::placeholders::_6));
|
});
|
||||||
m_interface->start();
|
m_interface->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +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)");
|
||||||
}
|
}
|
||||||
|
EWOLSA_VERBOSE(" get data Music: "<< _nbChunk);
|
||||||
ethread::UniqueLock lock(m_mutex);
|
ethread::UniqueLock 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()));
|
||||||
@ -103,7 +104,7 @@ void audio::ess::Music::load(const etk::String& _file, const etk::String& _name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ethread::UniqueLock lock(m_mutex);
|
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) {
|
void audio::ess::Music::play(const etk::String& _name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user