Browse Source

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
rdb 7 years ago
parent
commit
cd2ea97b1f
1 changed files with 16 additions and 0 deletions
  1. 16 0
      panda/src/audiotraits/openalAudioManager.cxx

+ 16 - 0
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;
+  }
 }
 
 /**