| 424 | } |
| 425 | |
| 426 | void AudioEngine::uncache(std::string_view filePath) |
| 427 | { |
| 428 | if (!_audioEngineImpl) |
| 429 | { |
| 430 | return; |
| 431 | } |
| 432 | auto audioIDsIter = _audioPathIDMap.find(filePath); |
| 433 | if (audioIDsIter != _audioPathIDMap.end()) |
| 434 | { |
| 435 | //@Note: For safely iterating elements from the audioID list, we need to copy the list |
| 436 | // since 'AudioEngine::remove' may be invoked in '_audioEngineImpl->stop' synchronously. |
| 437 | // If this happens, it will break the iteration, and crash will appear on some devices. |
| 438 | std::list<AUDIO_ID> copiedIDs(audioIDsIter->second); |
| 439 | |
| 440 | for (AUDIO_ID audioID : copiedIDs) |
| 441 | { |
| 442 | _audioEngineImpl->stop(audioID); |
| 443 | |
| 444 | auto itInfo = _audioIDInfoMap.find(audioID); |
| 445 | if (itInfo != _audioIDInfoMap.end()) |
| 446 | { |
| 447 | if (itInfo->second.profileHelper) |
| 448 | { |
| 449 | itInfo->second.profileHelper->audioIDs.remove(audioID); |
| 450 | } |
| 451 | _audioIDInfoMap.erase(audioID); |
| 452 | } |
| 453 | } |
| 454 | _audioPathIDMap.erase(filePath); |
| 455 | } |
| 456 | |
| 457 | if (_audioEngineImpl) |
| 458 | { |
| 459 | _audioEngineImpl->uncache(filePath); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | void AudioEngine::uncacheAll() |
| 464 | { |