void AudioEngineImpl::play2dImpl(AudioCache *cache, int audioID) {
//Note: It may be in sub thread or main thread :(
if (!*cache->_isDestroyed && cache->_state == AudioCache::State::READY) {
_threadMutex.lock();
auto playerIt = _audioPlayers.find(audioID);
if (playerIt != _audioPlayers.end()) {
// Trust it, or assert it out.
bool res = playerIt->second->play2d();
CC_ASSERT(res);
}
_threadMutex.unlock();
} else {
ALOGD("AudioEngineImpl::play2dImpl, cache was destroyed or not ready!");
auto iter = _audioPlayers.find(audioID);
if (iter != _audioPlayers.end()) {
iter->second->_removeByAudioEngine = true;
}
}
}
还有我多次遇到 在这个函数触发断言 CC_ASSERT(res); 播放音效返回的值非法。
