Forráskód Böngészése

fixed crash when deleting paused streamed AudioSources

Andrew Karpushin 11 éve
szülő
commit
9407204dee
1 módosított fájl, 8 hozzáadás és 7 törlés
  1. 8 7
      gameplay/src/AudioSource.cpp

+ 8 - 7
gameplay/src/AudioSource.cpp

@@ -30,13 +30,14 @@ AudioSource::~AudioSource()
 {
 {
     if (_alSource)
     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));
         AL_CHECK(alDeleteSources(1, &_alSource));
         _alSource = 0;
         _alSource = 0;