From 78818ca275769d37e514141a0cf3271c185b0d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felippe=20Dur=C3=A1n?= Date: Tue, 18 Jul 2017 00:12:20 -0300 Subject: [PATCH] Fix AudioEngine thread concurrency crash between myAlSourceNotificationCallback and _play2d iterating over _audioPlayers. (#18083) --- cocos/audio/apple/AudioEngine-inl.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index 06c9992d2e..7532654f90 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -215,6 +215,7 @@ ALvoid AudioEngineImpl::myAlSourceNotificationCallback(ALuint sid, ALuint notifi return; AudioPlayer* player = nullptr; + s_instance->_threadMutex.lock(); for (const auto& e : s_instance->_audioPlayers) { player = e.second; @@ -223,6 +224,7 @@ ALvoid AudioEngineImpl::myAlSourceNotificationCallback(ALuint sid, ALuint notifi player->wakeupRotateThread(); } } + s_instance->_threadMutex.unlock(); } AudioEngineImpl::AudioEngineImpl()