summaryrefslogtreecommitdiffstats
path: root/libao2/ao_openal.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-30 23:37:30 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-30 23:37:30 +0000
commitc8c416c516e031771b16f3b940a6ad0bfd7c3d2c (patch)
tree68398050d3be9a662d1ac427fddf908194b63d75 /libao2/ao_openal.c
parent1a976d453fc7c1a983f90d796028c42b6a59f681 (diff)
downloadmpv-c8c416c516e031771b16f3b940a6ad0bfd7c3d2c.tar.bz2
mpv-c8c416c516e031771b16f3b940a6ad0bfd7c3d2c.tar.xz
Reduce number of UnqueueBuffer calls
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25939 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2/ao_openal.c')
-rw-r--r--libao2/ao_openal.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index 57de5f9b01..f5e4acbd9e 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -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;
}
}
}