aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/opensl.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends/opensl.c')
-rw-r--r--Alc/backends/opensl.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index 1a104029..76cbaf1a 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -83,6 +83,10 @@ typedef struct SLDataLocator_AndroidSimpleBufferQueue {
#define SLPlayItf_SetPlayState(a,b) ((*(a))->SetPlayState((a),(b)))
+/* Should start using these generic callers instead of the name-specific ones above. */
+#define VCALL(obj, func) ((*(obj))->func((obj), EXTRACT_VCALL_ARGS
+#define VCALL0(obj, func) ((*(obj))->func((obj) EXTRACT_VCALL_ARGS
+
typedef struct {
/* engine interfaces */
@@ -97,6 +101,7 @@ typedef struct {
void *buffer;
ALuint bufferSize;
+ ALuint curBuffer;
ALuint frameSize;
} osl_data;
@@ -175,12 +180,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 +363,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 +375,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);
@@ -401,6 +412,25 @@ static ALCboolean opensl_start_playback(ALCdevice *Device)
static void opensl_stop_playback(ALCdevice *Device)
{
osl_data *data = Device->ExtraData;
+ SLPlayItf player;
+ SLAndroidSimpleBufferQueueItf bufferQueue;
+ SLresult result;
+
+ result = VCALL(data->bufferQueueObject,GetInterface)(SL_IID_PLAY, &player);
+ PRINTERR(result, "bufferQueue->GetInterface");
+ if(SL_RESULT_SUCCESS == result)
+ {
+ result = VCALL(player,SetPlayState)(SL_PLAYSTATE_STOPPED);
+ PRINTERR(result, "player->SetPlayState");
+ }
+
+ result = VCALL(data->bufferQueueObject,GetInterface)(SL_IID_BUFFERQUEUE, &bufferQueue);
+ PRINTERR(result, "bufferQueue->GetInterface");
+ if(SL_RESULT_SUCCESS == result)
+ {
+ result = VCALL0(bufferQueue,Clear)();
+ PRINTERR(result, "bufferQueue->Clear");
+ }
free(data->buffer);
data->buffer = NULL;
@@ -420,8 +450,6 @@ static const BackendFuncs opensl_funcs = {
NULL,
NULL,
NULL,
- ALCdevice_LockDefault,
- ALCdevice_UnlockDefault,
ALCdevice_GetLatencyDefault
};