diff --git a/cocos/audio/AudioEngine.cpp b/cocos/audio/AudioEngine.cpp index 9035daed66..423b6c84f9 100644 --- a/cocos/audio/AudioEngine.cpp +++ b/cocos/audio/AudioEngine.cpp @@ -65,8 +65,7 @@ AudioEngine::AudioEngineThreadPool* AudioEngine::s_threadPool = nullptr; bool AudioEngine::_isEnabled = true; AudioEngine::AudioInfo::AudioInfo() -: filePath(nullptr) -, profileHelper(nullptr) +: profileHelper(nullptr) , volume(1.0f) , loop(false) , duration(TIME_UNKNOWN) @@ -241,7 +240,7 @@ int AudioEngine::play2d(const std::string& filePath, bool loop, float volume, co auto& audioRef = _audioIDInfoMap[ret]; audioRef.volume = volume; audioRef.loop = loop; - audioRef.filePath = &it->first; + audioRef.filePath = it->first; if (profileHelper) { profileHelper->lastPlayTime = utils::gettime(); @@ -342,7 +341,7 @@ void AudioEngine::remove(int audioID) if (it->second.profileHelper) { it->second.profileHelper->audioIDs.remove(audioID); } - _audioPathIDMap[*it->second.filePath].remove(audioID); + _audioPathIDMap[it->second.filePath].remove(audioID); _audioIDInfoMap.erase(it); } } diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index 64cf02bb86..9345957826 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -672,7 +672,7 @@ void AudioEngineImpl::update(float dt) std::string filePath; if (player->_finishCallbak) { auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID]; - filePath = *audioInfo.filePath; + filePath = audioInfo.filePath; } AudioEngine::remove(audioID); diff --git a/cocos/audio/include/AudioEngine.h b/cocos/audio/include/AudioEngine.h index ce6a4aa9a7..f72eb59565 100644 --- a/cocos/audio/include/AudioEngine.h +++ b/cocos/audio/include/AudioEngine.h @@ -326,7 +326,7 @@ protected: struct AudioInfo { - const std::string* filePath; + std::string filePath; ProfileHelper* profileHelper; float volume; diff --git a/cocos/audio/win32/AudioEngine-win32.cpp b/cocos/audio/win32/AudioEngine-win32.cpp index 168e445b1f..24605942da 100644 --- a/cocos/audio/win32/AudioEngine-win32.cpp +++ b/cocos/audio/win32/AudioEngine-win32.cpp @@ -476,7 +476,7 @@ void AudioEngineImpl::update(float dt) std::string filePath; if (player->_finishCallbak) { auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID]; - filePath = *audioInfo.filePath; + filePath = audioInfo.filePath; } AudioEngine::remove(audioID);