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
+130 -72
View File
@@ -21,144 +21,202 @@
#include "config.h"
#include <stdlib.h>
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#include "alMain.h"
#include "AL/al.h"
#include "AL/alc.h"
#include "alu.h"
#include "threads.h"
#include "compat.h"
#include "backends/base.h"
typedef struct {
typedef struct ALCnullBackend {
DERIVE_FROM_TYPE(ALCbackend);
volatile int killNow;
ALvoid *thread;
} null_data;
althread_t thread;
} ALCnullBackend;
DECLARE_ALCBACKEND_VTABLE(ALCnullBackend);
static ALuint ALCnullBackend_mixerProc(ALvoid *ptr);
static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device);
static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, Destruct)
static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name);
static void ALCnullBackend_close(ALCnullBackend *self);
static ALCboolean ALCnullBackend_reset(ALCnullBackend *self);
static ALCboolean ALCnullBackend_start(ALCnullBackend *self);
static void ALCnullBackend_stop(ALCnullBackend *self);
static DECLARE_FORWARD2(ALCnullBackend, ALCbackend, ALCenum, captureSamples, void*, ALCuint)
static DECLARE_FORWARD(ALCnullBackend, ALCbackend, ALCuint, availableSamples)
static DECLARE_FORWARD(ALCnullBackend, ALCbackend, ALint64, getLatency)
static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, lock)
static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, unlock)
static const ALCchar nullDevice[] = "No Output";
static ALuint NullProc(ALvoid *ptr)
static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device)
{
ALCdevice *Device = (ALCdevice*)ptr;
null_data *data = (null_data*)Device->ExtraData;
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
SET_VTABLE2(ALCnullBackend, ALCbackend, self);
}
static ALuint ALCnullBackend_mixerProc(ALvoid *ptr)
{
ALCnullBackend *self = (ALCnullBackend*)ptr;
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
ALuint now, start;
ALuint64 avail, done;
const ALuint restTime = (ALuint64)Device->UpdateSize * 1000 /
Device->Frequency / 2;
SetRTPriority();
SetThreadName(MIXER_THREAD_NAME);
done = 0;
start = timeGetTime();
while(!data->killNow && Device->Connected)
while(!self->killNow && device->Connected)
{
now = timeGetTime();
avail = (ALuint64)(now-start) * Device->Frequency / 1000;
avail = (ALuint64)(now-start) * device->Frequency / 1000;
if(avail < done)
{
/* Timer wrapped. Add the remainder of the cycle to the available
* count and reset the number of samples done */
avail += (ALuint64)0xFFFFFFFFu*Device->Frequency/1000 - done;
/* Timer wrapped (50 days???). Add the remainder of the cycle to
* the available count and reset the number of samples done */
avail += (U64(1)<<32)*device->Frequency/1000 - done;
done = 0;
}
if(avail-done < Device->UpdateSize)
if(avail-done < device->UpdateSize)
{
ALuint restTime = (ALuint)((device->UpdateSize - (avail-done)) * 1000 /
device->Frequency);
Sleep(restTime);
continue;
}
while(avail-done >= Device->UpdateSize)
{
aluMixData(Device, NULL, Device->UpdateSize);
done += Device->UpdateSize;
}
do {
aluMixData(device, NULL, device->UpdateSize);
done += device->UpdateSize;
} while(avail-done >= device->UpdateSize);
}
return 0;
}
static ALCenum null_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
null_data *data;
if(!deviceName)
deviceName = nullDevice;
else if(strcmp(deviceName, nullDevice) != 0)
static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name)
{
ALCdevice *device;
if(!name)
name = nullDevice;
else if(strcmp(name, nullDevice) != 0)
return ALC_INVALID_VALUE;
data = (null_data*)calloc(1, sizeof(*data));
device = STATIC_CAST(ALCbackend, self)->mDevice;
device->DeviceName = strdup(name);
device->szDeviceName = strdup(deviceName);
device->ExtraData = data;
return ALC_NO_ERROR;
}
static void null_close_playback(ALCdevice *device)
static void ALCnullBackend_close(ALCnullBackend* UNUSED(self))
{
null_data *data = (null_data*)device->ExtraData;
free(data);
device->ExtraData = NULL;
}
static ALCboolean null_reset_playback(ALCdevice *device)
static ALCboolean ALCnullBackend_reset(ALCnullBackend *self)
{
null_data *data = (null_data*)device->ExtraData;
SetDefaultWFXChannelOrder(device);
data->thread = StartThread(NullProc, device);
if(data->thread == NULL)
return ALC_FALSE;
SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice);
return ALC_TRUE;
}
static void null_stop_playback(ALCdevice *device)
static ALCboolean ALCnullBackend_start(ALCnullBackend *self)
{
null_data *data = (null_data*)device->ExtraData;
if(!StartThread(&self->thread, ALCnullBackend_mixerProc, self))
return ALC_FALSE;
return ALC_TRUE;
}
if(!data->thread)
static void ALCnullBackend_stop(ALCnullBackend *self)
{
if(!self->thread)
return;
data->killNow = 1;
StopThread(data->thread);
data->thread = NULL;
self->killNow = 1;
StopThread(self->thread);
self->thread = NULL;
data->killNow = 0;
self->killNow = 0;
}
static const BackendFuncs null_funcs = {
null_open_playback,
null_close_playback,
null_reset_playback,
null_stop_playback,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
ALCboolean alc_null_init(BackendFuncs *func_list)
static void ALCnullBackend_Delete(ALCnullBackend *self)
{
free(self);
}
DEFINE_ALCBACKEND_VTABLE(ALCnullBackend);
typedef struct ALCnullBackendFactory {
DERIVE_FROM_TYPE(ALCbackendFactory);
} ALCnullBackendFactory;
#define ALCNULLBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCnullBackendFactory, ALCbackendFactory) } }
ALCbackendFactory *ALCnullBackendFactory_getFactory(void);
static ALCboolean ALCnullBackendFactory_init(ALCnullBackendFactory *self);
static DECLARE_FORWARD(ALCnullBackendFactory, ALCbackendFactory, void, deinit)
static ALCboolean ALCnullBackendFactory_querySupport(ALCnullBackendFactory *self, ALCbackend_Type type);
static void ALCnullBackendFactory_probe(ALCnullBackendFactory *self, enum DevProbe type);
static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
DEFINE_ALCBACKENDFACTORY_VTABLE(ALCnullBackendFactory);
ALCbackendFactory *ALCnullBackendFactory_getFactory(void)
{
static ALCnullBackendFactory factory = ALCNULLBACKENDFACTORY_INITIALIZER;
return STATIC_CAST(ALCbackendFactory, &factory);
}
static ALCboolean ALCnullBackendFactory_init(ALCnullBackendFactory* UNUSED(self))
{
*func_list = null_funcs;
return ALC_TRUE;
}
void alc_null_deinit(void)
static ALCboolean ALCnullBackendFactory_querySupport(ALCnullBackendFactory* UNUSED(self), ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
return ALC_TRUE;
return ALC_FALSE;
}
void alc_null_probe(enum DevProbe type)
static void ALCnullBackendFactory_probe(ALCnullBackendFactory* UNUSED(self), enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(nullDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(nullDevice);
AppendAllDevicesList(nullDevice);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
{
ALCnullBackend *backend;
assert(type == ALCbackend_Playback);
backend = calloc(1, sizeof(*backend));
if(!backend) return NULL;
ALCnullBackend_Construct(backend, device);
return STATIC_CAST(ALCbackend, backend);
}