From cd2ea97b1ffb65512f5ee8ba0665f46345ef7795 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:38:20 +0100 Subject: [PATCH] openal: fix issues with uncache_sound not uncaching sound: * Previously it only looked for the resolved path, but sounds are not stored with resolved path in the cache (possibly a different bug?) * It only uncached samples, not streams Fixes #428 --- panda/src/audiotraits/openalAudioManager.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index a6ac7ba06d..c205f55402 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -534,6 +534,9 @@ uncache_sound(const Filename &file_name) { vfs->resolve_filename(path, get_model_path()); SampleCache::iterator sci = _sample_cache.find(path); + if (sci == _sample_cache.end()) { + sci = _sample_cache.find(file_name); + } if (sci != _sample_cache.end()) { SoundData *sd = (*sci).second; if (sd->_client_count == 0) { @@ -542,6 +545,19 @@ uncache_sound(const Filename &file_name) { delete sd; } } + + ExpirationQueue::iterator exqi; + for (exqi = _expiring_streams.begin(); exqi != _expiring_streams.end();) { + SoundData *sd = (SoundData *)(*exqi); + if (sd->_client_count == 0) { + if (sd->_movie->get_filename() == path || + sd->_movie->get_filename() == file_name) { + exqi = _expiring_streams.erase(exqi); + continue; + } + } + ++exqi; + } } /**