目前发现是AudioEngine-inl.mm update中 if (player->_removeByAudioEngine) {
AudioEngine::remove(audioID);
_threadMutex.lock();
it = _audioPlayers.erase(it);
_threadMutex.unlock();
delete player;
_unusedSourcesPool.push_back(alSource);
} else if (player->_ready && sourceState == AL_STOPPED) {
ccstd::string filePath;
if (player->_finishCallbak) {
auto &audioInfo = AudioEngine::sAudioIDInfoMap[audioID];
filePath = *audioInfo.filePath;
}
AudioEngine::remove(audioID);
_threadMutex.lock();
it = _audioPlayers.erase(it);
_threadMutex.unlock();
if (auto sche = _scheduler.lock()) {
if (player->_finishCallbak) {
auto cb = player->_finishCallbak;
sche->performFunctionInCocosThread([audioID, cb, filePath]() {
cb(audioID, filePath); //IDEA: callback will delay 50ms
});
}
}
delete player;
_unusedSourcesPool.push_back(alSource);
} else {
++it;
}
player->_ready && sourceState == AL_STOPPED 判断为AL_STOPPED remove AudioEngine::remove(audioID); 触发条件是 初始化了广告sdk adMax adMob, 毕现,不初始化广告则不出现