mirror of https://github.com/axmolengine/axmol.git
Cleanup AudioEngine resource after exiting NewAudioEngineTest. (#17675)
* Unschedules update in AudioEngine implementation while AudioEngine::end is called. * Cleanup AudioEngine resource after exiting NewAudioEngineTest.
This commit is contained in:
parent
75d0ebfefc
commit
3c1e36c2c3
|
@ -192,12 +192,18 @@ static id s_AudioEngineSessionHandler = nullptr;
|
|||
AudioEngineImpl::AudioEngineImpl()
|
||||
: _lazyInitLoop(true)
|
||||
, _currentAudioID(0)
|
||||
, _scheduler(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AudioEngineImpl::~AudioEngineImpl()
|
||||
{
|
||||
if (_scheduler != nullptr)
|
||||
{
|
||||
_scheduler->unschedule(CC_SCHEDULE_SELECTOR(AudioEngineImpl::update), this);
|
||||
}
|
||||
|
||||
if (s_ALContext) {
|
||||
alDeleteSources(MAX_AUDIOINSTANCES, _alSources);
|
||||
|
||||
|
|
|
@ -112,12 +112,18 @@ static ALCcontext *s_ALContext = nullptr;
|
|||
AudioEngineImpl::AudioEngineImpl()
|
||||
: _lazyInitLoop(true)
|
||||
, _currentAudioID(0)
|
||||
, _scheduler(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AudioEngineImpl::~AudioEngineImpl()
|
||||
{
|
||||
if (_scheduler != nullptr)
|
||||
{
|
||||
_scheduler->unschedule(CC_SCHEDULE_SELECTOR(AudioEngineImpl::update), this);
|
||||
}
|
||||
|
||||
if (s_ALContext) {
|
||||
alDeleteSources(MAX_AUDIOINSTANCES, _alSources);
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ AudioEngineImpl::AudioEngineImpl()
|
|||
|
||||
AudioEngineImpl::~AudioEngineImpl()
|
||||
{
|
||||
auto scheduler = cocos2d::Director::getInstance()->getScheduler();
|
||||
scheduler->unschedule(schedule_selector(AudioEngineImpl::update), this);
|
||||
_audioCaches.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,12 @@ std::string AudioEngineTestDemo::title() const
|
|||
return "New Audio Engine Test";
|
||||
}
|
||||
|
||||
void AudioEngineTestDemo::onBackCallback(cocos2d::Ref* sender)
|
||||
{
|
||||
AudioEngine::end();
|
||||
TestCase::onBackCallback(sender);
|
||||
}
|
||||
|
||||
// AudioControlTest
|
||||
bool AudioControlTest::init()
|
||||
{
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
|
||||
virtual std::string title() const override;
|
||||
virtual void onExit() override;
|
||||
|
||||
virtual void onBackCallback(cocos2d::Ref* sender) override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<bool> _isDestroyed;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue