Updated openal-soft to version 1.15.1

This commit is contained in:
fysx
2014-01-30 10:19:28 +01:00
parent 33d979caf6
commit f0fa37f4ad
164 changed files with 38848 additions and 21244 deletions
+77 -30
View File
@@ -22,13 +22,13 @@
#include "config.h"
#include <stdlib.h>
#include "alMain.h"
#include "AL/al.h"
#include "AL/alc.h"
#include "alu.h"
#include <SLES/OpenSLES.h>
#ifdef HAVE_ANDROID
#if 1
#include <SLES/OpenSLES_Android.h>
#else
extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
@@ -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;
@@ -152,9 +157,13 @@ static const char *res_str(SLresult result)
case SL_RESULT_UNKNOWN_ERROR: return "Unknown error";
case SL_RESULT_OPERATION_ABORTED: return "Operation aborted";
case SL_RESULT_CONTROL_LOST: return "Control lost";
#ifdef HAVE_OPENSL_1_1
#ifdef SL_RESULT_READONLY
case SL_RESULT_READONLY: return "ReadOnly";
#endif
#ifdef SL_RESULT_ENGINEOPTION_UNSUPPORTED
case SL_RESULT_ENGINEOPTION_UNSUPPORTED: return "Engine option unsupported";
#endif
#ifdef SL_RESULT_SOURCE_SINK_INCOMPATIBLE
case SL_RESULT_SOURCE_SINK_INCOMPATIBLE: return "Source/Sink incompatible";
#endif
}
@@ -171,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;
}
@@ -233,7 +246,7 @@ static ALCenum opensl_open_playback(ALCdevice *Device, const ALCchar *deviceName
return ALC_INVALID_VALUE;
}
Device->szDeviceName = strdup(deviceName);
Device->DeviceName = strdup(deviceName);
Device->ExtraData = data;
return ALC_NO_ERROR;
@@ -244,6 +257,10 @@ static void opensl_close_playback(ALCdevice *Device)
{
osl_data *data = Device->ExtraData;
if(data->bufferQueueObject != NULL)
SLObjectItf_Destroy(data->bufferQueueObject);
data->bufferQueueObject = NULL;
SLObjectItf_Destroy(data->outputMix);
data->outputMix = NULL;
@@ -259,16 +276,13 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
{
osl_data *data = Device->ExtraData;
SLDataLocator_AndroidSimpleBufferQueue loc_bufq;
SLAndroidSimpleBufferQueueItf bufferQueue;
SLDataLocator_OutputMix loc_outmix;
SLDataFormat_PCM format_pcm;
SLDataSource audioSrc;
SLDataSink audioSnk;
SLPlayItf player;
SLInterfaceID id;
SLboolean req;
SLresult result;
ALuint i;
Device->UpdateSize = (ALuint64)Device->UpdateSize * 44100 / Device->Frequency;
@@ -294,13 +308,8 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
format_pcm.bitsPerSample = BytesFromDevFmt(Device->FmtType) * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(Device->FmtChans);
#ifdef HAVE_OPENSL_1_1
format_pcm.endianness = SL_BYTEORDER_NATIVE;
#elif _BYTE_ORDER == _BIG_ENDIAN
format_pcm.endianness = SL_BYTEORDER_BIGENDIAN;
#else
format_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
#endif
format_pcm.endianness = IS_LITTLE_ENDIAN ? SL_BYTEORDER_LITTLEENDIAN :
SL_BYTEORDER_BIGENDIAN;
audioSrc.pLocator = &loc_bufq;
audioSrc.pFormat = &format_pcm;
@@ -311,6 +320,10 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
audioSnk.pFormat = NULL;
if(data->bufferQueueObject != NULL)
SLObjectItf_Destroy(data->bufferQueueObject);
data->bufferQueueObject = NULL;
result = SLEngineItf_CreateAudioPlayer(data->engine, &data->bufferQueueObject, &audioSrc, &audioSnk, 1, &id, &req);
PRINTERR(result, "engine->CreateAudioPlayer");
if(SL_RESULT_SUCCESS == result)
@@ -318,11 +331,29 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
result = SLObjectItf_Realize(data->bufferQueueObject, SL_BOOLEAN_FALSE);
PRINTERR(result, "bufferQueue->Realize");
}
if(SL_RESULT_SUCCESS == result)
if(SL_RESULT_SUCCESS != result)
{
result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_BUFFERQUEUE, &bufferQueue);
PRINTERR(result, "bufferQueue->GetInterface");
if(data->bufferQueueObject != NULL)
SLObjectItf_Destroy(data->bufferQueueObject);
data->bufferQueueObject = NULL;
return ALC_FALSE;
}
return ALC_TRUE;
}
static ALCboolean opensl_start_playback(ALCdevice *Device)
{
osl_data *data = Device->ExtraData;
SLAndroidSimpleBufferQueueItf bufferQueue;
SLPlayItf player;
SLresult result;
ALuint i;
result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_BUFFERQUEUE, &bufferQueue);
PRINTERR(result, "bufferQueue->GetInterface");
if(SL_RESULT_SUCCESS == result)
{
result = (*bufferQueue)->RegisterCallback(bufferQueue, opensl_callback, Device);
@@ -332,7 +363,7 @@ static ALCboolean opensl_reset_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;
@@ -344,10 +375,12 @@ static ALCboolean opensl_reset_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);
@@ -379,10 +412,25 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
static void opensl_stop_playback(ALCdevice *Device)
{
osl_data *data = Device->ExtraData;
SLPlayItf player;
SLAndroidSimpleBufferQueueItf bufferQueue;
SLresult result;
if(data->bufferQueueObject != NULL)
SLObjectItf_Destroy(data->bufferQueueObject);
data->bufferQueueObject = NULL;
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;
@@ -394,13 +442,15 @@ static const BackendFuncs opensl_funcs = {
opensl_open_playback,
opensl_close_playback,
opensl_reset_playback,
opensl_start_playback,
opensl_stop_playback,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
NULL,
ALCdevice_GetLatencyDefault
};
@@ -418,11 +468,8 @@ void alc_opensl_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(opensl_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(opensl_device);
AppendAllDevicesList(opensl_device);
break;
case CAPTURE_DEVICE_PROBE:
break;