Sfoglia il codice sorgente

fixed crash when deleting paused streamed AudioSources

Andrew Karpushin 11 anni fa
parent
commit
9407204dee
1 ha cambiato i file con 8 aggiunte e 7 eliminazioni
  1. 8 7
      gameplay/src/AudioSource.cpp

+ 8 - 7
gameplay/src/AudioSource.cpp

@@ -30,13 +30,14 @@ AudioSource::~AudioSource()
 {
     if (_alSource)
     {
-        if (getState() == PLAYING || getState() == STOPPED)
-        {
-            // Remove the source from the controller's set of currently playing sources.
-            AudioController* audioController = Game::getInstance()->getAudioController();
-            GP_ASSERT(audioController);
-            audioController->removePlayingSource(this);
-        }
+        // Remove the source from the controller's set of currently playing sources
+        // regardless of the source's state. E.g. when the AudioController::pause is called
+        // all sources are paused but still remain in controller's set of currently 
+        // playing sources. When the source is deleted afterwards, it should be removed
+        // from controller's set regardless of its playing state.
+        AudioController* audioController = Game::getInstance()->getAudioController();
+        GP_ASSERT(audioController);
+        audioController->removePlayingSource(this);
 
         AL_CHECK(alDeleteSources(1, &_alSource));
         _alSource = 0;