Просмотр исходного кода

Fix for not releasing audio device on Android

OpenAL soft has the pause/resume extensions on Android. So, these are
used when going to and coming back from background.

Fixes #1649
Üstün Ergenoglu 10 лет назад
Родитель
Сommit
a87e87f317
2 измененных файлов с 8 добавлено и 0 удалено
  1. 6 0
      gameplay/src/AudioController.cpp
  2. 2 0
      gameplay/src/Base.h

+ 6 - 0
gameplay/src/AudioController.cpp

@@ -81,11 +81,17 @@ void AudioController::pause()
         _pausingSource = NULL;
         _pausingSource = NULL;
         itr++;
         itr++;
     }
     }
+#ifdef ALC_SOFT_pause_device
+    alcDevicePauseSOFT(_alcDevice);
+#endif
 }
 }
 
 
 void AudioController::resume()
 void AudioController::resume()
 {   
 {   
     alcMakeContextCurrent(_alcContext);
     alcMakeContextCurrent(_alcContext);
+#ifdef ALC_SOFT_pause_device
+    alcDeviceResumeSOFT(_alcDevice);
+#endif
 
 
     std::set<AudioSource*>::iterator itr = _playingSources.begin();
     std::set<AudioSource*>::iterator itr = _playingSources.begin();
 
 

+ 2 - 0
gameplay/src/Base.h

@@ -182,6 +182,8 @@ extern int strcmpnocase(const char* s1, const char* s2);
 #ifdef __ANDROID__
 #ifdef __ANDROID__
     #include <AL/al.h>
     #include <AL/al.h>
     #include <AL/alc.h>
     #include <AL/alc.h>
+    #define AL_ALEXT_PROTOTYPES
+    #include <AL/alext.h>
 #elif WIN32
 #elif WIN32
     #define AL_LIBTYPE_STATIC
     #define AL_LIBTYPE_STATIC
     #include <AL/al.h>
     #include <AL/al.h>