mirror of https://github.com/axmolengine/axmol.git
Fix dead-lock when play/stopAll immidiately
This commit is contained in:
parent
dda5628876
commit
e250fe3707
|
@ -276,11 +276,13 @@ void AudioCache::readDataTask(unsigned int selfId)
|
|||
}
|
||||
}
|
||||
|
||||
// Set before invokingPlayCallbacks, otherwise, may cause dead-lock
|
||||
_isLoadingFinished = true;
|
||||
|
||||
//FIXME: Why to invoke play callback first? Should it be after 'load' callback?
|
||||
invokingPlayCallbacks();
|
||||
invokingLoadCallbacks();
|
||||
|
||||
_isLoadingFinished = true;
|
||||
_readDataTaskMutex.unlock();
|
||||
ALOGVV("readDataTask end, cache id=%u", selfId);
|
||||
}
|
||||
|
|
|
@ -495,8 +495,9 @@ void AudioEngineImpl::_updateLocked(float dt)
|
|||
finishCallback(audioID, filePath); //FIXME: callback will delay 50ms
|
||||
});
|
||||
#endif
|
||||
player->setCache(nullptr); // it's safe for player didn't free audio cache
|
||||
}
|
||||
// clear cache when audio player finsihed properly
|
||||
player->setCache(nullptr);
|
||||
delete player;
|
||||
_alSourceUsed[alSource] = false;
|
||||
}
|
||||
|
|
|
@ -306,11 +306,13 @@ void AudioCache::readDataTask(unsigned int selfId)
|
|||
decoder->close();
|
||||
AudioDecoderManager::destroyDecoder(decoder);
|
||||
|
||||
// Set before invokingPlayCallbacks, otherwise, may cause dead-lock
|
||||
_isLoadingFinished = true;
|
||||
|
||||
//FIXME: Why to invoke play callback first? Should it be after 'load' callback?
|
||||
invokingPlayCallbacks();
|
||||
invokingLoadCallbacks();
|
||||
|
||||
_isLoadingFinished = true;
|
||||
if (_state != State::READY)
|
||||
{
|
||||
_state = State::FAILED;
|
||||
|
|
|
@ -751,9 +751,9 @@ void AudioEngineImpl::_updateLocked(float dt)
|
|||
_finishCallbacks.push_back([finishCallback = std::move(player->_finishCallbak), audioID, filePath = std::move(filePath)](){
|
||||
finishCallback(audioID, filePath); // FIXME: callback will delay 50ms
|
||||
});
|
||||
player->setCache(nullptr); // it's safe for player didn't free audio cache
|
||||
}
|
||||
|
||||
// clear cache when audio player finsihed properly
|
||||
player->setCache(nullptr);
|
||||
delete player;
|
||||
_unusedSourcesPool.push_back(alSource);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue