[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:08:27 +02:00
parent 686ab25ed8
commit f55fa25f04
12 changed files with 55 additions and 55 deletions

View File

@ -34,7 +34,7 @@ void audio::ess::LoadedFile::decode() {
EWOLSA_ERROR("End decode OGG : " << m_file << " size=" << m_nbSamples);
}
audio::ess::LoadedFile::LoadedFile(const std::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
@ -42,7 +42,7 @@ audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanR
m_nbSamples(0),
m_nbChanRequested(_nbChanRequested),
m_requestedTime(1) {
std::string tmpName = etk::tolower(m_file);
etk::String tmpName = etk::tolower(m_file);
// select the corect Loader :
if (etk::end_with(tmpName, ".wav") == true) {
m_data = audio::ess::wav::loadAudioFile(m_file, m_nbChanRequested);

View File

@ -25,15 +25,15 @@ namespace audio {
ememory::SharedPtr<std::thread> m_thread;
#endif
public:
LoadedFile(const std::string& _fileName, int8_t _nbChanRequested=1);
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
~LoadedFile();
std::string m_file;
etk::String m_file;
int32_t m_nbSamples;
int32_t m_nbChanRequested;
int32_t m_requestedTime;
std::vector<float> m_data;
etk::Vector<float> m_data;
public:
const std::string& getName() {
const etk::String& getName() {
return m_file;
};
void decode();

View File

@ -46,8 +46,8 @@ static long localTellFunc(void *datasource) {
return file->fileTell();
}
std::vector<float> audio::ess::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
std::vector<float> out;
etk::Vector<float> audio::ess::ogg::loadAudioFile(const etk::String& _filename, int8_t _nbChan) {
etk::Vector<float> out;
OggVorbis_File vf;
int32_t eof=0;
int32_t current_section;

View File

@ -10,7 +10,7 @@
namespace audio {
namespace ess {
namespace ogg {
std::vector<float> loadAudioFile(const std::string& _filename, int8_t _nbChan);
etk::Vector<float> loadAudioFile(const etk::String& _filename, int8_t _nbChan);
}
}

View File

@ -57,8 +57,8 @@ typedef struct {
#define COMPR_G721 (64)
#define COMPR_MPEG (80)
std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
std::vector<float> out;
etk::Vector<float> audio::ess::wav::loadAudioFile(const etk::String& _filename, int8_t _nbChan) {
etk::Vector<float> out;
waveHeader myHeader;
memset(&myHeader, 0, sizeof(waveHeader));
etk::FSNode fileAccess(_filename);

View File

@ -10,7 +10,7 @@
namespace audio {
namespace ess {
namespace wav {
std::vector<float> loadAudioFile(const std::string& _filename, int8_t _nbChan);
etk::Vector<float> loadAudioFile(const etk::String& _filename, int8_t _nbChan);
}
}
}

View File

@ -16,8 +16,8 @@ audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _m
m_manager(_manager) {
std::unique_lock<std::mutex> lock(m_mutex);
//Set stereo output:
std::vector<audio::channel> channelMap;
channelMap.push_back(audio::channel_frontCenter);
etk::Vector<audio::channel> channelMap;
channelMap.pushBack(audio::channel_frontCenter);
m_interface = m_manager->createOutput(48000,
channelMap,
audio::format_float,
@ -56,8 +56,8 @@ static bool playData(const ememory::SharedPtr<audio::ess::LoadedFile>& _file, in
|| _file->m_data.size() == 0) {
return true;
}
int32_t processTimeMax = std::min(_nbSample, _file->m_nbSamples - _position);
processTimeMax = std::max(0, processTimeMax);
int32_t processTimeMax = etk::min(_nbSample, _file->m_nbSamples - _position);
processTimeMax = etk::max(0, processTimeMax);
float * pointer = _bufferInterlace;
const float * newData = &_file->m_data[_position];
//EWOLSA_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " playTime=" <<m_playTime << " nbCannels=" << nbChannels);
@ -80,7 +80,7 @@ void audio::ess::Effects::onDataNeeded(void* _data,
const size_t& _nbChunk,
enum audio::format _format,
uint32_t _sampleRate,
const std::vector<audio::channel>& _map){
const etk::Vector<audio::channel>& _map){
if (_format != audio::format_float) {
EWOLSA_ERROR("call wrong type ... (need float)");
}
@ -96,7 +96,7 @@ void audio::ess::Effects::onDataNeeded(void* _data,
}
}
void audio::ess::Effects::load(const std::string& _file, const std::string& _name) {
void audio::ess::Effects::load(const etk::String& _file, const etk::String& _name) {
// load the file:
ememory::SharedPtr<audio::ess::LoadedFile> tmp = ememory::makeShared<audio::ess::LoadedFile>(_file, 2);
if (tmp == nullptr) {
@ -112,20 +112,20 @@ void audio::ess::Effects::load(const std::string& _file, const std::string& _nam
}
}
if (-1 <= id) {
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
m_list.pushBack(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
} else {
m_list[id].second = tmp;
}
}
int32_t audio::ess::Effects::getId(const std::string& _name) {
int32_t audio::ess::Effects::getId(const etk::String& _name) {
std::unique_lock<std::mutex> lock(m_mutex);
for (size_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii].first == _name) {
return iii;
}
}
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,nullptr));
m_list.pushBack(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,nullptr));
EWOLSA_WARNING("Can not find element name : '" << _name << "' added it ... (empty) ");
return m_list.size()-1;
}
@ -137,10 +137,10 @@ 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<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>(m_list[_id].second, 0));
m_playing.pushBack(etk::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) {
void audio::ess::Effects::play(const etk::String& _name, const vec3& _pos) {
play(getId(_name),_pos);
}

View File

@ -28,13 +28,13 @@ namespace audio {
const size_t& _nbChunk,
enum audio::format _format,
uint32_t _sampleRate,
const std::vector<audio::channel>& _map);
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
const etk::Vector<audio::channel>& _map);
etk::Vector<etk::Pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>> m_playing; //!< current music read
etk::Vector<etk::Pair<etk::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);
void play(const std::string& _name, const vec3& _pos = vec3(0,0,0));
void load(const etk::String& _file, const etk::String& _name);
int32_t getId(const etk::String& _name);
void play(const etk::String& _name, const vec3& _pos = vec3(0,0,0));
void play(int32_t _id, const vec3& _pos = vec3(0,0,0));
void stop();
void clear();

View File

@ -29,14 +29,14 @@ void audio::ess::unInit() {
g_audioManager.reset();
}
void audio::ess::soundSetParse(const std::string& _data) {
void audio::ess::soundSetParse(const etk::String& _data) {
ejson::Document doc;
doc.parse(_data);
ejson::Object obj = doc["musics"].toObject();
if ( obj.exist() == true
&& g_music != nullptr) {
for (auto &it : obj.getKeys()) {
std::string file = obj[it].toString().get();
etk::String file = obj[it].toString().get();
EWOLSA_INFO("load Music : '" << it << "' file=" << file);
g_music->load(file, it);
}
@ -45,18 +45,18 @@ void audio::ess::soundSetParse(const std::string& _data) {
if ( obj.exist() == true
&& g_effects != nullptr) {
for (auto &it : obj.getKeys()) {
std::string file = obj[it].toString().get();
etk::String file = obj[it].toString().get();
EWOLSA_INFO("load Effect : '" << it << "' file=" << file);
g_effects->load(file, it);
}
}
}
void audio::ess::soundSetLoad(const std::string& _file) {
void audio::ess::soundSetLoad(const etk::String& _file) {
soundSetParse(etk::FSNodeReadAllData(_file));
}
void audio::ess::musicPlay(const std::string& _name) {
void audio::ess::musicPlay(const etk::String& _name) {
if (g_music == nullptr) {
return;
}
@ -98,7 +98,7 @@ bool audio::ess::musicGetMute() {
return g_audioManager->getMute("MUSIC");
}
int32_t audio::ess::effectGetId(const std::string& _name) {
int32_t audio::ess::effectGetId(const etk::String& _name) {
if (g_effects == nullptr) {
return -1;
}
@ -112,7 +112,7 @@ void audio::ess::effectPlay(int32_t _id, const vec3& _pos) {
g_effects->play(_id, _pos);
}
void audio::ess::effectPlay(const std::string& _name, const vec3& _pos) {
void audio::ess::effectPlay(const etk::String& _name, const vec3& _pos) {
if (g_effects == nullptr) {
return;
}

View File

@ -29,18 +29,18 @@ namespace audio {
* @brief Parse a JSON configuration data of a soundset
* @param[in] _data JSON string data to parse
*/
void soundSetParse(const std::string& _data);
void soundSetParse(const etk::String& _data);
/**
* @brief Parse a configuration file of a soundset
* @param[in] _file JSON file to parse
*/
void soundSetLoad(const std::string& _file);
void soundSetLoad(const etk::String& _file);
/**
* @brief Play a music with his name
* @param[in] _name Name of the music (not the Path)
*/
void musicPlay(const std::string& _name);
void musicPlay(const etk::String& _name);
/**
* @brief Stop the music played
*/
@ -72,7 +72,7 @@ namespace audio {
* @param[in] _name Name of the effects
* @return the effect ID or -1 if it does not exist...
*/
int32_t effectGetId(const std::string& _name);
int32_t effectGetId(const etk::String& _name);
/**
* @brief Play an effect with his ID
* @param[in] _id Id of the effect to play
@ -84,7 +84,7 @@ namespace audio {
* @param[in] _name Name of the effect to play
* @param[in] _pos position of the efffect is played (not used / not implemented)
*/
void effectPlay(const std::string& _name, const vec3& _pos=vec3(0,0,0));
void effectPlay(const etk::String& _name, const vec3& _pos=vec3(0,0,0));
/**
* @brief Set the effects volume
* @param[in] _dB apply decibel volume at the effects [-100..100]

View File

@ -17,9 +17,9 @@ audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manag
m_position(0) {
std::unique_lock<std::mutex> lock(m_mutex);
//Set stereo output:
std::vector<audio::channel> channelMap;
channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(audio::channel_frontRight);
etk::Vector<audio::channel> channelMap;
channelMap.pushBack(audio::channel_frontLeft);
channelMap.pushBack(audio::channel_frontRight);
m_interface = m_manager->createOutput(48000,
channelMap,
audio::format_float,
@ -59,7 +59,7 @@ void audio::ess::Music::onDataNeeded(void* _data,
const size_t& _nbChunk,
enum audio::format _format,
uint32_t _sampleRate,
const std::vector<audio::channel>& _map){
const etk::Vector<audio::channel>& _map){
if (_format != audio::format_float) {
EWOLSA_ERROR("call wrong type ... (need float)");
}
@ -76,8 +76,8 @@ void audio::ess::Music::onDataNeeded(void* _data,
if (m_current->m_data.size() == 0) {
return;
}
int32_t processTimeMax = std::min(int32_t(_nbChunk*_map.size()), int32_t(m_current->m_nbSamples - m_position));
processTimeMax = std::max(0, processTimeMax);
int32_t processTimeMax = etk::min(int32_t(_nbChunk*_map.size()), int32_t(m_current->m_nbSamples - m_position));
processTimeMax = etk::max(0, processTimeMax);
float * pointer = static_cast<float*>(_data);
float * newData = &m_current->m_data[m_position];
EWOLSA_VERBOSE("AUDIO : Play slot... nb sample : " << processTimeMax << " map=" << _map << " _nbChunk=" << _nbChunk);
@ -92,7 +92,7 @@ void audio::ess::Music::onDataNeeded(void* _data,
}
}
void audio::ess::Music::load(const std::string& _file, const std::string& _name) {
void audio::ess::Music::load(const etk::String& _file, const etk::String& _name) {
auto it = m_list.find(_name);
if (it != m_list.end()) {
return;
@ -103,10 +103,10 @@ void audio::ess::Music::load(const std::string& _file, const std::string& _name)
return;
}
std::unique_lock<std::mutex> lock(m_mutex);
m_list.insert(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
m_list.insert(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
}
void audio::ess::Music::play(const std::string& _name) {
void audio::ess::Music::play(const etk::String& _name) {
auto it = m_list.find(_name);
if (it == m_list.end()) {
EWOLSA_ERROR("Can not Play music : " << _name);

View File

@ -10,7 +10,7 @@
#include <audio/river/Manager.hpp>
#include <audio/ess/LoadedFile.hpp>
#include <mutex>
#include <map>
#include <etk/Map.hpp>
namespace audio {
@ -29,14 +29,14 @@ namespace audio {
const size_t& _nbChunk,
enum audio::format _format,
uint32_t _sampleRate,
const std::vector<audio::channel>& _map);
const etk::Vector<audio::channel>& _map);
ememory::SharedPtr<audio::ess::LoadedFile> m_current; //!< current music read
int32_t m_position; //!< current position of music read
std::map<std::string, ememory::SharedPtr<audio::ess::LoadedFile> > m_list; //!< list of all music loaded
etk::Map<etk::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);
void load(const etk::String& _file, const etk::String& _name);
void play(const etk::String& _name);
void stop();
void clear();
};