Răsfoiți Sursa

Autoplaying streaming sound if OpenAL stops playing it because of dequeued buffers, adjusted streaming buffer default sizes

Ivan Safrin 11 ani în urmă
părinte
comite
3825606a2b
2 a modificat fișierele cu 8 adăugiri și 3 ștergeri
  1. 2 2
      Core/Contents/Include/PolySound.h
  2. 6 1
      Core/Contents/Source/PolySound.cpp

+ 2 - 2
Core/Contents/Include/PolySound.h

@@ -43,8 +43,8 @@
 #define ALOtherErrorStr "AL error: unknown error"
 
 #define BUFFER_SIZE 32768
-#define STREAMING_BUFFER_COUNT 2
-#define STREAMING_BUFFER_SIZE 16384
+#define STREAMING_BUFFER_COUNT 4
+#define STREAMING_BUFFER_SIZE 4096
 
 namespace Polycode {
 	

+ 6 - 1
Core/Contents/Source/PolySound.cpp

@@ -144,7 +144,12 @@ void Sound::updateStream() {
             alSourceQueueBuffers(soundSource, 1, &buffer);
         }
     }
-    
+
+    ALenum state;
+    alGetSourcei(soundSource, AL_SOURCE_STATE, &state);
+    if(state != AL_PLAYING) {
+        alSourcePlay(soundSource);
+    }
 }
 
 bool Sound::updateALBuffer(ALuint buffer) {