Skip to content

Commit 474491a

Browse files
James Chenminggo
authored andcommitted
Call 'update' method in 'stop/stopAll' to cleanup immediately (#17846)
1 parent 85529ea commit 474491a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cocos/audio/apple/AudioEngine-inl.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *bids)
504504
//Note: Don't set the flag to false here, it should be set in 'update' function.
505505
// Otherwise, the state got from alSourceState may be wrong
506506
// _alSourceUsed[player->_alSource] = false;
507+
508+
// Call 'update' method to cleanup immediately since the schedule may be cancelled without any notification.
509+
update(0.0f);
507510
}
508511

509512
void AudioEngineImpl::stopAll()
@@ -518,6 +521,9 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *bids)
518521
// {
519522
// _alSourceUsed[_alSources[index]] = false;
520523
// }
524+
525+
// Call 'update' method to cleanup immediately since the schedule may be cancelled without any notification.
526+
update(0.0f);
521527
}
522528

523529
float AudioEngineImpl::getDuration(int audioID)

cocos/audio/win32/AudioEngine-win32.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ void AudioEngineImpl::stop(int audioID)
360360
//Note: Don't set the flag to false here, it should be set in 'update' function.
361361
// Otherwise, the state got from alSourceState may be wrong
362362
// _alSourceUsed[player->_alSource] = false;
363+
364+
// Call 'update' method to cleanup immediately since the schedule may be cancelled without any notification.
365+
update(0.0f);
363366
}
364367

365368
void AudioEngineImpl::stopAll()
@@ -374,6 +377,9 @@ void AudioEngineImpl::stopAll()
374377
// {
375378
// _alSourceUsed[_alSources[index]] = false;
376379
// }
380+
381+
// Call 'update' method to cleanup immediately since the schedule may be cancelled without any notification.
382+
update(0.0f);
377383
}
378384

379385
float AudioEngineImpl::getDuration(int audioID)

0 commit comments

Comments
 (0)