aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-01-15 15:27:38 -0800
committerChris Robinson <[email protected]>2014-01-15 15:27:38 -0800
commit5fdc3c093e03e7c3241245befbfcee828472e337 (patch)
tree39a103a6ede1b5023b19d2677d7f56aa81d5dba3 /Alc
parent173999804594a7a2fbc7ee93e0dfd5d0b20a0f59 (diff)
Don't use the same buffer segment for enqueueing in OpenSL
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/opensl.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index ed5ce3f6..cba4c856 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -97,6 +97,7 @@ typedef struct {
void *buffer;
ALuint bufferSize;
+ ALuint curBuffer;
ALuint frameSize;
} osl_data;
@@ -175,12 +176,16 @@ static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
ALCdevice *Device = context;
osl_data *data = Device->ExtraData;
+ ALvoid *buf;
SLresult result;
- aluMixData(Device, data->buffer, data->bufferSize/data->frameSize);
+ buf = (ALbyte*)data->buffer + data->curBuffer*data->bufferSize;
+ aluMixData(Device, buf, data->bufferSize/data->frameSize);
- result = (*bq)->Enqueue(bq, data->buffer, data->bufferSize);
+ result = (*bq)->Enqueue(bq, buf, data->bufferSize);
PRINTERR(result, "bq->Enqueue");
+
+ data->curBuffer = (data->curBuffer+1) % Device->NumUpdates;
}
@@ -354,7 +359,7 @@ static ALCboolean opensl_start_playback(ALCdevice *Device)
{
data->frameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType);
data->bufferSize = Device->UpdateSize * data->frameSize;
- data->buffer = calloc(1, data->bufferSize);
+ data->buffer = calloc(Device->NumUpdates, data->bufferSize);
if(!data->buffer)
{
result = SL_RESULT_MEMORY_FAILURE;
@@ -366,10 +371,12 @@ static ALCboolean opensl_start_playback(ALCdevice *Device)
{
if(SL_RESULT_SUCCESS == result)
{
- result = (*bufferQueue)->Enqueue(bufferQueue, data->buffer, data->bufferSize);
+ ALvoid *buf = (ALbyte*)data->buffer + i*data->bufferSize;
+ result = (*bufferQueue)->Enqueue(bufferQueue, buf, data->bufferSize);
PRINTERR(result, "bufferQueue->Enqueue");
}
}
+ data->curBuffer = 0;
if(SL_RESULT_SUCCESS == result)
{
result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_PLAY, &player);