[DEV] correct playing of audio music

This commit is contained in:
Edouard DUPIN 2015-09-29 21:12:20 +02:00
parent f580ec38e3
commit ccc8460635
2 changed files with 4 additions and 5 deletions

View File

@ -30,10 +30,10 @@ void audio::ess::LoadedFile::threadCall() {
} }
void audio::ess::LoadedFile::decode() { void audio::ess::LoadedFile::decode() {
EWOLSA_INFO("Start decode OGG : " << m_file); EWOLSA_ERROR("Start decode OGG : " << m_file);
m_data = audio::ess::ogg::loadAudioFile(m_file, m_nbChanRequested); m_data = audio::ess::ogg::loadAudioFile(m_file, m_nbChanRequested);
m_nbSamples = m_data.size(); m_nbSamples = m_data.size();
EWOLSA_INFO("End decode OGG : " << m_file << " size=" << m_nbSamples); 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 std::string& _fileName, int8_t _nbChanRequested) :
@ -57,7 +57,7 @@ audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanR
#else #else
m_thread = std11::make_shared<std11::thread>(&audio::ess::LoadedFile::threadCall, this); m_thread = std11::make_shared<std11::thread>(&audio::ess::LoadedFile::threadCall, this);
if (m_thread == nullptr) { if (m_thread == nullptr) {
GALE_ERROR("Can not create thread ..."); EWOLSA_ERROR("Can not create thread ...");
return; return;
} }
#endif #endif

View File

@ -68,7 +68,6 @@ void audio::ess::Music::onDataNeeded(void* _data,
if (_format != audio::format_int16) { if (_format != audio::format_int16) {
EWOLSA_ERROR("call wrong type ... (need int16_t)"); EWOLSA_ERROR("call wrong type ... (need int16_t)");
} }
return;
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::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()));
@ -86,7 +85,7 @@ void audio::ess::Music::onDataNeeded(void* _data,
processTimeMax = std::max(0, processTimeMax); processTimeMax = std::max(0, processTimeMax);
int16_t * pointer = static_cast<int16_t*>(_data); int16_t * pointer = static_cast<int16_t*>(_data);
int16_t * newData = &m_current->m_data[m_position]; int16_t * newData = &m_current->m_data[m_position];
EWOLSA_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " map=" << _map << " _nbChunk=" << _nbChunk); EWOLSA_VERBOSE("AUDIO : Play slot... nb sample : " << processTimeMax << " map=" << _map << " _nbChunk=" << _nbChunk);
for (int32_t iii=0; iii<processTimeMax; iii++) { for (int32_t iii=0; iii<processTimeMax; iii++) {
*pointer++ = *newData++; *pointer++ = *newData++;
} }