File tree Expand file tree Collapse file tree 5 files changed +23
-0
lines changed
tests/cpp-tests/Classes/NewAudioEngineTest Expand file tree Collapse file tree 5 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -192,12 +192,18 @@ -(void) dealloc
192
192
AudioEngineImpl::AudioEngineImpl ()
193
193
: _lazyInitLoop(true )
194
194
, _currentAudioID(0 )
195
+ , _scheduler(nullptr )
195
196
{
196
197
197
198
}
198
199
199
200
AudioEngineImpl::~AudioEngineImpl ()
200
201
{
202
+ if (_scheduler != nullptr )
203
+ {
204
+ _scheduler->unschedule (CC_SCHEDULE_SELECTOR (AudioEngineImpl::update), this );
205
+ }
206
+
201
207
if (s_ALContext) {
202
208
alDeleteSources (MAX_AUDIOINSTANCES, _alSources);
203
209
Original file line number Diff line number Diff line change @@ -112,12 +112,18 @@ static ALCcontext *s_ALContext = nullptr;
112
112
AudioEngineImpl::AudioEngineImpl ()
113
113
: _lazyInitLoop(true )
114
114
, _currentAudioID(0 )
115
+ , _scheduler(nullptr )
115
116
{
116
117
117
118
}
118
119
119
120
AudioEngineImpl::~AudioEngineImpl ()
120
121
{
122
+ if (_scheduler != nullptr )
123
+ {
124
+ _scheduler->unschedule (CC_SCHEDULE_SELECTOR (AudioEngineImpl::update), this );
125
+ }
126
+
121
127
if (s_ALContext) {
122
128
alDeleteSources (MAX_AUDIOINSTANCES, _alSources);
123
129
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ AudioEngineImpl::AudioEngineImpl()
38
38
39
39
AudioEngineImpl::~AudioEngineImpl ()
40
40
{
41
+ auto scheduler = cocos2d::Director::getInstance ()->getScheduler ();
42
+ scheduler->unschedule (schedule_selector (AudioEngineImpl::update), this );
41
43
_audioCaches.clear ();
42
44
}
43
45
Original file line number Diff line number Diff line change @@ -207,6 +207,12 @@ std::string AudioEngineTestDemo::title() const
207
207
return " New Audio Engine Test" ;
208
208
}
209
209
210
+ void AudioEngineTestDemo::onBackCallback (cocos2d::Ref* sender)
211
+ {
212
+ AudioEngine::end ();
213
+ TestCase::onBackCallback (sender);
214
+ }
215
+
210
216
// AudioControlTest
211
217
bool AudioControlTest::init ()
212
218
{
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ class AudioEngineTestDemo : public TestCase
41
41
42
42
virtual std::string title () const override ;
43
43
virtual void onExit () override ;
44
+
45
+ virtual void onBackCallback (cocos2d::Ref* sender) override ;
46
+
44
47
protected:
45
48
std::shared_ptr<bool > _isDestroyed;
46
49
};
You can’t perform that action at this time.
0 commit comments