[MPlayer-cvslog] r25939 - trunk/libao2/ao_openal.c

reimar subversion at mplayerhq.hu
Thu Jan 31 00:37:30 CET 2008


Author: reimar
Date: Thu Jan 31 00:37:30 2008
New Revision: 25939

Log:
Reduce number of UnqueueBuffer calls

Modified:
   trunk/libao2/ao_openal.c

Modified: trunk/libao2/ao_openal.c
==============================================================================
--- trunk/libao2/ao_openal.c	(original)
+++ trunk/libao2/ao_openal.c	Thu Jan 31 00:37:30 2008
@@ -161,10 +161,16 @@ static void unqueue_buffers(void) {
   ALint p;
   int s, i;
   for (s = 0;  s < ao_data.channels; s++) {
+    int till_wrap = NUM_BUF - unqueue_buf[s];
     alGetSourcei(sources[s], AL_BUFFERS_PROCESSED, &p);
-    for (i = 0; i < p; i++) {
-      alSourceUnqueueBuffers(sources[s], 1, &buffers[s][unqueue_buf[s]]);
-      unqueue_buf[s] = (unqueue_buf[s] + 1) % NUM_BUF;
+    if (p >= till_wrap) {
+      alSourceUnqueueBuffers(sources[s], till_wrap, &buffers[s][unqueue_buf[s]]);
+      unqueue_buf[s] = 0;
+      p -= till_wrap;
+    }
+    if (p) {
+      alSourceUnqueueBuffers(sources[s], p, &buffers[s][unqueue_buf[s]]);
+      unqueue_buf[s] += p;
     }
   }
 }



More information about the MPlayer-cvslog mailing list