mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 20:51:22 +02:00
Updated openal-soft to version 1.15.1
This commit is contained in:
@@ -23,9 +23,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alu.h"
|
||||
#include "threads.h"
|
||||
|
||||
#include <sndio.h>
|
||||
|
||||
@@ -33,86 +34,8 @@
|
||||
static const ALCchar sndio_device[] = "SndIO Default";
|
||||
|
||||
|
||||
static void *sndio_handle;
|
||||
#ifdef HAVE_DYNLOAD
|
||||
#define MAKE_FUNC(x) static typeof(x) * p##x
|
||||
MAKE_FUNC(sio_initpar);
|
||||
MAKE_FUNC(sio_open);
|
||||
MAKE_FUNC(sio_close);
|
||||
MAKE_FUNC(sio_setpar);
|
||||
MAKE_FUNC(sio_getpar);
|
||||
MAKE_FUNC(sio_getcap);
|
||||
MAKE_FUNC(sio_onmove);
|
||||
MAKE_FUNC(sio_write);
|
||||
MAKE_FUNC(sio_read);
|
||||
MAKE_FUNC(sio_start);
|
||||
MAKE_FUNC(sio_stop);
|
||||
MAKE_FUNC(sio_nfds);
|
||||
MAKE_FUNC(sio_pollfd);
|
||||
MAKE_FUNC(sio_revents);
|
||||
MAKE_FUNC(sio_eof);
|
||||
MAKE_FUNC(sio_setvol);
|
||||
MAKE_FUNC(sio_onvol);
|
||||
|
||||
#define sio_initpar psio_initpar
|
||||
#define sio_open psio_open
|
||||
#define sio_close psio_close
|
||||
#define sio_setpar psio_setpar
|
||||
#define sio_getpar psio_getpar
|
||||
#define sio_getcap psio_getcap
|
||||
#define sio_onmove psio_onmove
|
||||
#define sio_write psio_write
|
||||
#define sio_read psio_read
|
||||
#define sio_start psio_start
|
||||
#define sio_stop psio_stop
|
||||
#define sio_nfds psio_nfds
|
||||
#define sio_pollfd psio_pollfd
|
||||
#define sio_revents psio_revents
|
||||
#define sio_eof psio_eof
|
||||
#define sio_setvol psio_setvol
|
||||
#define sio_onvol psio_onvol
|
||||
#endif
|
||||
|
||||
|
||||
static ALCboolean sndio_load(void)
|
||||
{
|
||||
if(!sndio_handle)
|
||||
{
|
||||
#ifdef HAVE_DYNLOAD
|
||||
sndio_handle = LoadLib("libsndio.so");
|
||||
if(!sndio_handle)
|
||||
return ALC_FALSE;
|
||||
|
||||
#define LOAD_FUNC(f) do { \
|
||||
p##f = GetSymbol(sndio_handle, #f); \
|
||||
if(p##f == NULL) { \
|
||||
CloseLib(sndio_handle); \
|
||||
sndio_handle = NULL; \
|
||||
return ALC_FALSE; \
|
||||
} \
|
||||
} while(0)
|
||||
LOAD_FUNC(sio_initpar);
|
||||
LOAD_FUNC(sio_open);
|
||||
LOAD_FUNC(sio_close);
|
||||
LOAD_FUNC(sio_setpar);
|
||||
LOAD_FUNC(sio_getpar);
|
||||
LOAD_FUNC(sio_getcap);
|
||||
LOAD_FUNC(sio_onmove);
|
||||
LOAD_FUNC(sio_write);
|
||||
LOAD_FUNC(sio_read);
|
||||
LOAD_FUNC(sio_start);
|
||||
LOAD_FUNC(sio_stop);
|
||||
LOAD_FUNC(sio_nfds);
|
||||
LOAD_FUNC(sio_pollfd);
|
||||
LOAD_FUNC(sio_revents);
|
||||
LOAD_FUNC(sio_eof);
|
||||
LOAD_FUNC(sio_setvol);
|
||||
LOAD_FUNC(sio_onvol);
|
||||
#undef LOAD_FUNC
|
||||
#else
|
||||
sndio_handle = (void*)0xDEADBEEF;
|
||||
#endif
|
||||
}
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
@@ -124,7 +47,7 @@ typedef struct {
|
||||
ALsizei data_size;
|
||||
|
||||
volatile int killNow;
|
||||
ALvoid *thread;
|
||||
althread_t thread;
|
||||
} sndio_data;
|
||||
|
||||
|
||||
@@ -136,6 +59,7 @@ static ALuint sndio_proc(ALvoid *ptr)
|
||||
size_t wrote;
|
||||
|
||||
SetRTPriority();
|
||||
SetThreadName(MIXER_THREAD_NAME);
|
||||
|
||||
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
|
||||
|
||||
@@ -151,7 +75,9 @@ static ALuint sndio_proc(ALvoid *ptr)
|
||||
if(wrote == 0)
|
||||
{
|
||||
ERR("sio_write failed\n");
|
||||
ALCdevice_Lock(device);
|
||||
aluHandleDisconnect(device);
|
||||
ALCdevice_Unlock(device);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -185,7 +111,7 @@ static ALCenum sndio_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;
|
||||
@@ -208,7 +134,6 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
sio_initpar(&par);
|
||||
|
||||
par.rate = device->Frequency;
|
||||
|
||||
par.pchan = ((device->FmtChans != DevFmtMono) ? 2 : 1);
|
||||
|
||||
switch(device->FmtType)
|
||||
@@ -222,8 +147,6 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
par.sig = 0;
|
||||
break;
|
||||
case DevFmtFloat:
|
||||
device->FmtType = DevFmtShort;
|
||||
/* fall-through */
|
||||
case DevFmtShort:
|
||||
par.bits = 16;
|
||||
par.sig = 1;
|
||||
@@ -232,6 +155,14 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
par.bits = 16;
|
||||
par.sig = 0;
|
||||
break;
|
||||
case DevFmtInt:
|
||||
par.bits = 32;
|
||||
par.sig = 1;
|
||||
break;
|
||||
case DevFmtUInt:
|
||||
par.bits = 32;
|
||||
par.sig = 0;
|
||||
break;
|
||||
}
|
||||
par.le = SIO_LE_NATIVE;
|
||||
|
||||
@@ -239,40 +170,21 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
par.appbufsz = device->UpdateSize * (device->NumUpdates-1);
|
||||
if(!par.appbufsz) par.appbufsz = device->UpdateSize;
|
||||
|
||||
|
||||
if(!sio_setpar(data->sndHandle, &par) || !sio_getpar(data->sndHandle, &par))
|
||||
{
|
||||
ERR("Failed to set device parameters\n");
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(par.rate != device->Frequency)
|
||||
{
|
||||
if((device->Flags&DEVICE_FREQUENCY_REQUEST))
|
||||
ERR("Failed to set frequency %uhz, got %uhz instead\n", device->Frequency, par.rate);
|
||||
device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
|
||||
device->Frequency = par.rate;
|
||||
}
|
||||
|
||||
if(par.pchan != ChannelsFromDevFmt(device->FmtChans))
|
||||
{
|
||||
if(par.pchan != 1 && par.pchan != 2)
|
||||
{
|
||||
ERR("Unhandled channel count: %u\n", par.pchan);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
if((device->Flags&DEVICE_CHANNELS_REQUEST))
|
||||
ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans), par.pchan);
|
||||
device->Flags &= ~DEVICE_CHANNELS_REQUEST;
|
||||
device->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo);
|
||||
}
|
||||
|
||||
if(par.bits != par.bps*8)
|
||||
{
|
||||
ERR("Padded samples not supported (%u of %u bits)\n", par.bits, par.bps*8);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->Frequency = par.rate;
|
||||
device->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo);
|
||||
|
||||
if(par.bits == 8 && par.sig == 1)
|
||||
device->FmtType = DevFmtByte;
|
||||
else if(par.bits == 8 && par.sig == 0)
|
||||
@@ -281,18 +193,27 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
device->FmtType = DevFmtShort;
|
||||
else if(par.bits == 16 && par.sig == 0)
|
||||
device->FmtType = DevFmtUShort;
|
||||
else if(par.bits == 32 && par.sig == 1)
|
||||
device->FmtType = DevFmtInt;
|
||||
else if(par.bits == 32 && par.sig == 0)
|
||||
device->FmtType = DevFmtUInt;
|
||||
else
|
||||
{
|
||||
ERR("Unhandled sample format: %s %u-bit\n", (par.sig?"signed":"unsigned"), par.bits);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
|
||||
device->UpdateSize = par.round;
|
||||
device->NumUpdates = (par.bufsz/par.round) + 1;
|
||||
|
||||
SetDefaultChannelOrder(device);
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static ALCboolean sndio_start_playback(ALCdevice *device)
|
||||
{
|
||||
sndio_data *data = device->ExtraData;
|
||||
|
||||
if(!sio_start(data->sndHandle))
|
||||
{
|
||||
@@ -300,11 +221,10 @@ static ALCboolean sndio_reset_playback(ALCdevice *device)
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->data_size = device->UpdateSize * par.bps * par.pchan;
|
||||
data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
data->thread = StartThread(sndio_proc, device);
|
||||
if(data->thread == NULL)
|
||||
if(!StartThread(&data->thread, sndio_proc, device))
|
||||
{
|
||||
sio_stop(data->sndHandle);
|
||||
free(data->mix_data);
|
||||
@@ -339,13 +259,15 @@ static const BackendFuncs sndio_funcs = {
|
||||
sndio_open_playback,
|
||||
sndio_close_playback,
|
||||
sndio_reset_playback,
|
||||
sndio_start_playback,
|
||||
sndio_stop_playback,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
ALCdevice_GetLatencyDefault
|
||||
};
|
||||
|
||||
ALCboolean alc_sndio_init(BackendFuncs *func_list)
|
||||
@@ -358,22 +280,14 @@ ALCboolean alc_sndio_init(BackendFuncs *func_list)
|
||||
|
||||
void alc_sndio_deinit(void)
|
||||
{
|
||||
#ifdef HAVE_DYNLOAD
|
||||
if(sndio_handle)
|
||||
CloseLib(sndio_handle);
|
||||
sndio_handle = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void alc_sndio_probe(enum DevProbe type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_PROBE:
|
||||
AppendDeviceList(sndio_device);
|
||||
break;
|
||||
case ALL_DEVICE_PROBE:
|
||||
AppendAllDeviceList(sndio_device);
|
||||
AppendAllDevicesList(sndio_device);
|
||||
break;
|
||||
case CAPTURE_DEVICE_PROBE:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user