Updated OpenAL Soft to 1.17.2.

This commit is contained in:
Alex Szpakowski
2016-10-29 16:12:27 -03:00
parent 8bdcc87460
commit 3dd3f1074b
30 changed files with 721 additions and 296 deletions
+5 -2
View File
@@ -677,6 +677,7 @@ static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
unsigned int rate;
const char *funcerr;
int allowmmap;
int dir;
int err;
switch(device->FmtType)
@@ -770,7 +771,7 @@ static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
}
CHECK(snd_pcm_hw_params_set_channels(self->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans)));
/* set rate (implicitly constrains period/buffer parameters) */
if(GetConfigValueBool(al_string_get_cstr(device->DeviceName), "alsa", "allow-resampler", 0))
if(!GetConfigValueBool(al_string_get_cstr(device->DeviceName), "alsa", "allow-resampler", 0))
{
if(snd_pcm_hw_params_set_rate_resample(self->pcmHandle, hp, 0) < 0)
ERR("Failed to disable ALSA resampler\n");
@@ -787,7 +788,9 @@ static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
/* retrieve configuration info */
CHECK(snd_pcm_hw_params_get_access(hp, &access));
CHECK(snd_pcm_hw_params_get_period_size(hp, &periodSizeInFrames, NULL));
CHECK(snd_pcm_hw_params_get_periods(hp, &periods, NULL));
CHECK(snd_pcm_hw_params_get_periods(hp, &periods, &dir));
if(dir != 0)
WARN("Inexact period count: %u (%d)\n", periods, dir);
snd_pcm_hw_params_free(hp);
hp = NULL;
+24 -18
View File
@@ -137,8 +137,8 @@ static OSStatus ca_capture_callback(void *inRefCon, AudioUnitRenderActionFlags *
static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName)
{
ComponentDescription desc;
Component comp;
AudioComponentDescription desc;
AudioComponent comp;
ca_data *data;
OSStatus err;
@@ -154,19 +154,19 @@ static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName)
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
comp = FindNextComponent(NULL, &desc);
comp = AudioComponentFindNext(NULL, &desc);
if(comp == NULL)
{
ERR("FindNextComponent failed\n");
ERR("AudioComponentFindNext failed\n");
return ALC_INVALID_VALUE;
}
data = calloc(1, sizeof(*data));
err = OpenAComponent(comp, &data->audioUnit);
err = AudioComponentInstanceNew(comp, &data->audioUnit);
if(err != noErr)
{
ERR("OpenAComponent failed\n");
ERR("AudioComponentInstanceNew failed\n");
free(data);
return ALC_INVALID_VALUE;
}
@@ -176,7 +176,7 @@ static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName)
if(err != noErr)
{
ERR("AudioUnitInitialize failed\n");
CloseComponent(data->audioUnit);
AudioComponentInstanceDispose(data->audioUnit);
free(data);
return ALC_INVALID_VALUE;
}
@@ -191,7 +191,7 @@ static void ca_close_playback(ALCdevice *device)
ca_data *data = (ca_data*)device->ExtraData;
AudioUnitUninitialize(data->audioUnit);
CloseComponent(data->audioUnit);
AudioComponentInstanceDispose(data->audioUnit);
free(data);
device->ExtraData = NULL;
@@ -374,12 +374,13 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
AudioStreamBasicDescription hardwareFormat; // The hardware format
AudioStreamBasicDescription outputFormat; // The AudioUnit output format
AURenderCallbackStruct input;
ComponentDescription desc;
AudioComponentDescription desc;
AudioDeviceID inputDevice;
UInt32 outputFrameCount;
UInt32 propertySize;
AudioObjectPropertyAddress propertyAddress;
UInt32 enableIO;
Component comp;
AudioComponent comp;
ca_data *data;
OSStatus err;
@@ -395,10 +396,10 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
desc.componentFlagsMask = 0;
// Search for component with given description
comp = FindNextComponent(NULL, &desc);
comp = AudioComponentFindNext(NULL, &desc);
if(comp == NULL)
{
ERR("FindNextComponent failed\n");
ERR("AudioComponentFindNext failed\n");
return ALC_INVALID_VALUE;
}
@@ -406,10 +407,10 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
device->ExtraData = data;
// Open the component
err = OpenAComponent(comp, &data->audioUnit);
err = AudioComponentInstanceNew(comp, &data->audioUnit);
if(err != noErr)
{
ERR("OpenAComponent failed\n");
ERR("AudioComponentInstanceNew failed\n");
goto error;
}
@@ -432,11 +433,16 @@ static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName)
}
// Get the default input device
propertySize = sizeof(AudioDeviceID);
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &inputDevice);
propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = kAudioObjectPropertyElementMaster;
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &propertySize, &inputDevice);
if(err != noErr)
{
ERR("AudioHardwareGetProperty failed\n");
ERR("AudioObjectGetPropertyData failed\n");
goto error;
}
@@ -596,7 +602,7 @@ error:
if(data->audioConverter)
AudioConverterDispose(data->audioConverter);
if(data->audioUnit)
CloseComponent(data->audioUnit);
AudioComponentInstanceDispose(data->audioUnit);
free(data);
device->ExtraData = NULL;
@@ -613,7 +619,7 @@ static void ca_close_capture(ALCdevice *device)
destroy_buffer_list(data->bufferList);
AudioConverterDispose(data->audioConverter);
CloseComponent(data->audioUnit);
AudioComponentInstanceDispose(data->audioUnit);
free(data);
device->ExtraData = NULL;
+5 -6
View File
@@ -60,7 +60,7 @@
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
#ifdef HAVE_DYNLOAD
@@ -145,13 +145,12 @@ static BOOL CALLBACK DSoundEnumDevices(GUID *guid, const WCHAR *desc, const WCHA
{
const DevMap *iter;
al_string_copy_wcstr(&entry.name, desc);
if(count == 0)
al_string_append_cstr(&entry.name, DEVNAME_TAIL);
else
al_string_copy_cstr(&entry.name, DEVNAME_HEAD);
al_string_append_wcstr(&entry.name, desc);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&entry.name, str);
}
+13 -12
View File
@@ -62,7 +62,7 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FormFactor, 0x1da5d803, 0xd492, 0x4edd, 0x
#define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT)
#define X7DOT1_WIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_FRONT_LEFT_OF_CENTER|SPEAKER_FRONT_RIGHT_OF_CENTER)
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
typedef struct {
@@ -125,10 +125,13 @@ static void get_device_name(IMMDevice *device, al_string *name)
PROPVARIANT pvname;
HRESULT hr;
al_string_copy_cstr(name, DEVNAME_HEAD);
hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
if(FAILED(hr))
{
WARN("OpenPropertyStore failed: 0x%08lx\n", hr);
al_string_append_cstr(name, "Unknown Device Name");
return;
}
@@ -136,11 +139,17 @@ static void get_device_name(IMMDevice *device, al_string *name)
hr = IPropertyStore_GetValue(ps, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pvname);
if(FAILED(hr))
{
WARN("GetValue Device_FriendlyName failed: 0x%08lx\n", hr);
al_string_append_cstr(name, "Unknown Device Name");
}
else if(pvname.vt == VT_LPWSTR)
al_string_copy_wcstr(name, pvname.pwszVal);
al_string_append_wcstr(name, pvname.pwszVal);
else
{
WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvname.vt);
al_string_append_cstr(name, "Unknown Device Name");
}
PropVariantClear(&pvname);
IPropertyStore_Release(ps);
@@ -193,12 +202,10 @@ static void add_device(IMMDevice *device, LPCWSTR devid, vector_DevMap *list)
const DevMap *iter;
al_string_copy(&entry.name, tmpname);
if(count == 0)
al_string_append_cstr(&entry.name, DEVNAME_TAIL);
else
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&entry.name, str);
}
@@ -755,10 +762,7 @@ static HRESULT ALCmmdevPlayback_openProxy(ALCmmdevPlayback *self)
{
self->client = ptr;
if(al_string_empty(device->DeviceName))
{
get_device_name(self->mmdev, &device->DeviceName);
al_string_append_cstr(&device->DeviceName, DEVNAME_TAIL);
}
}
if(FAILED(hr))
@@ -1412,10 +1416,7 @@ static HRESULT ALCmmdevCapture_openProxy(ALCmmdevCapture *self)
{
self->client = ptr;
if(al_string_empty(device->DeviceName))
{
get_device_name(self->mmdev, &device->DeviceName);
al_string_append_cstr(&device->DeviceName, DEVNAME_TAIL);
}
}
if(FAILED(hr))
+225 -27
View File
@@ -22,10 +22,12 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <unistd.h>
#include <errno.h>
@@ -51,11 +53,175 @@
#define SOUND_MIXER_WRITE MIXER_WRITE
#endif
#if defined(SOUND_VERSION) && (SOUND_VERSION < 0x040000)
#define ALC_OSS_COMPAT
#endif
#ifndef SNDCTL_AUDIOINFO
#define ALC_OSS_COMPAT
#endif
static const ALCchar oss_device[] = "OSS Default";
/*
* FreeBSD strongly discourages the use of specific devices,
* such as those returned in oss_audioinfo.devnode
*/
#ifdef __FreeBSD__
#define ALC_OSS_DEVNODE_TRUC
#endif
static const char *oss_driver = "/dev/dsp";
static const char *oss_capture = "/dev/dsp";
struct oss_device {
const ALCchar *handle;
const char *path;
struct oss_device *next;
};
static struct oss_device oss_playback = {
"OSS Default",
"/dev/dsp",
NULL
};
static struct oss_device oss_capture = {
"OSS Default",
"/dev/dsp",
NULL
};
#ifdef ALC_OSS_COMPAT
static void ALCossListPopulate(struct oss_device *UNUSED(playback), struct oss_device *UNUSED(capture))
{
}
#else
#ifndef HAVE_STRNLEN
static size_t strnlen(const char *str, size_t maxlen)
{
const char *end = memchr(str, 0, maxlen);
if(!end) return maxlen;
return end - str;
}
#endif
static void ALCossListAppend(struct oss_device *list, const char *handle, size_t hlen, const char *path, size_t plen)
{
struct oss_device *next;
struct oss_device *last;
size_t i;
/* skip the first item "OSS Default" */
last = list;
next = list->next;
#ifdef ALC_OSS_DEVNODE_TRUC
for(i = 0;i < plen;i++)
{
if(path[i] == '.')
{
if(strncmp(path + i, handle + hlen + i - plen, plen - i) == 0)
hlen = hlen + i - plen;
plen = i;
}
}
#else
(void)i;
#endif
if(handle[0] == '\0')
{
handle = path;
hlen = plen;
}
while(next != NULL)
{
if(strncmp(next->path, path, plen) == 0)
return;
last = next;
next = next->next;
}
next = (struct oss_device*)malloc(sizeof(struct oss_device) + hlen + plen + 2);
next->handle = (char*)(next + 1);
next->path = next->handle + hlen + 1;
next->next = NULL;
last->next = next;
strncpy((char*)next->handle, handle, hlen);
((char*)next->handle)[hlen] = '\0';
strncpy((char*)next->path, path, plen);
((char*)next->path)[plen] = '\0';
TRACE("Got device \"%s\", \"%s\"\n", next->handle, next->path);
}
static void ALCossListPopulate(struct oss_device *playback, struct oss_device *capture)
{
struct oss_sysinfo si;
struct oss_audioinfo ai;
int fd, i;
if((fd=open("/dev/mixer", O_RDONLY)) < 0)
{
ERR("Could not open /dev/mixer\n");
return;
}
if(ioctl(fd, SNDCTL_SYSINFO, &si) == -1)
{
ERR("SNDCTL_SYSINFO failed: %s\n", strerror(errno));
goto done;
}
for(i = 0;i < si.numaudios;i++)
{
const char *handle;
size_t len;
ai.dev = i;
if(ioctl(fd, SNDCTL_AUDIOINFO, &ai) == -1)
{
ERR("SNDCTL_AUDIOINFO (%d) failed: %s\n", i, strerror(errno));
continue;
}
if(ai.devnode[0] == '\0')
continue;
if(ai.handle[0] != '\0')
{
len = strnlen(ai.handle, sizeof(ai.handle));
handle = ai.handle;
}
else
{
len = strnlen(ai.name, sizeof(ai.name));
handle = ai.name;
}
if((ai.caps&DSP_CAP_INPUT) && capture != NULL)
ALCossListAppend(capture, handle, len, ai.devnode, strnlen(ai.devnode, sizeof(ai.devnode)));
if((ai.caps&DSP_CAP_OUTPUT) && playback != NULL)
ALCossListAppend(playback, handle, len, ai.devnode, strnlen(ai.devnode, sizeof(ai.devnode)));
}
done:
close(fd);
}
#endif
static void ALCossListFree(struct oss_device *list)
{
struct oss_device *cur;
if(list == NULL)
return;
/* skip the first item "OSS Default" */
cur = list->next;
list->next = NULL;
while(cur != NULL)
{
struct oss_device *next = cur->next;
free(cur);
cur = next;
}
}
static int log2i(ALCuint x)
{
@@ -68,7 +234,6 @@ static int log2i(ALCuint x)
return y;
}
typedef struct ALCplaybackOSS {
DERIVE_FROM_TYPE(ALCbackend);
@@ -152,19 +317,29 @@ static void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device)
static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name)
{
struct oss_device *dev = &oss_playback;
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
if(!name)
name = oss_device;
else if(strcmp(name, oss_device) != 0)
return ALC_INVALID_VALUE;
name = dev->handle;
else
{
while (dev != NULL)
{
if (strcmp(dev->handle, name) == 0)
break;
dev = dev->next;
}
if (dev == NULL)
return ALC_INVALID_VALUE;
}
self->killNow = 0;
self->fd = open(oss_driver, O_WRONLY);
self->fd = open(dev->path, O_WRONLY);
if(self->fd == -1)
{
ERR("Could not open %s: %s\n", oss_driver, strerror(errno));
ERR("Could not open %s: %s\n", dev->path, strerror(errno));
return ALC_INVALID_VALUE;
}
@@ -382,6 +557,7 @@ static void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device)
static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
struct oss_device *dev = &oss_capture;
int numFragmentsLogSize;
int log2FragmentSize;
unsigned int periods;
@@ -393,14 +569,23 @@ static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
char *err;
if(!name)
name = oss_device;
else if(strcmp(name, oss_device) != 0)
return ALC_INVALID_VALUE;
name = dev->handle;
else
{
while (dev != NULL)
{
if (strcmp(dev->handle, name) == 0)
break;
dev = dev->next;
}
if (dev == NULL)
return ALC_INVALID_VALUE;
}
self->fd = open(oss_capture, O_RDONLY);
self->fd = open(dev->path, O_RDONLY);
if(self->fd == -1)
{
ERR("Could not open %s: %s\n", oss_capture, strerror(errno));
ERR("Could not open %s: %s\n", dev->path, strerror(errno));
return ALC_INVALID_VALUE;
}
@@ -546,7 +731,7 @@ typedef struct ALCossBackendFactory {
ALCbackendFactory *ALCossBackendFactory_getFactory(void);
static ALCboolean ALCossBackendFactory_init(ALCossBackendFactory *self);
static DECLARE_FORWARD(ALCossBackendFactory, ALCbackendFactory, void, deinit)
static void ALCossBackendFactory_deinit(ALCossBackendFactory *self);
static ALCboolean ALCossBackendFactory_querySupport(ALCossBackendFactory *self, ALCbackend_Type type);
static void ALCossBackendFactory_probe(ALCossBackendFactory *self, enum DevProbe type);
static ALCbackend* ALCossBackendFactory_createBackend(ALCossBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
@@ -562,12 +747,19 @@ ALCbackendFactory *ALCossBackendFactory_getFactory(void)
ALCboolean ALCossBackendFactory_init(ALCossBackendFactory* UNUSED(self))
{
ConfigValueStr(NULL, "oss", "device", &oss_driver);
ConfigValueStr(NULL, "oss", "capture", &oss_capture);
ConfigValueStr(NULL, "oss", "device", &oss_playback.path);
ConfigValueStr(NULL, "oss", "capture", &oss_capture.path);
return ALC_TRUE;
}
void ALCossBackendFactory_deinit(ALCossBackendFactory* UNUSED(self))
{
ALCossListFree(&oss_playback);
ALCossListFree(&oss_capture);
}
ALCboolean ALCossBackendFactory_querySupport(ALCossBackendFactory* UNUSED(self), ALCbackend_Type type)
{
if(type == ALCbackend_Playback || type == ALCbackend_Capture)
@@ -581,21 +773,27 @@ void ALCossBackendFactory_probe(ALCossBackendFactory* UNUSED(self), enum DevProb
{
case ALL_DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(oss_driver, &buf) == 0)
#endif
AppendAllDevicesList(oss_device);
struct oss_device *cur = &oss_playback;
ALCossListFree(cur);
ALCossListPopulate(cur, NULL);
while (cur != NULL)
{
AppendAllDevicesList(cur->handle);
cur = cur->next;
}
}
break;
case CAPTURE_DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(oss_capture, &buf) == 0)
#endif
AppendCaptureDeviceList(oss_device);
struct oss_device *cur = &oss_capture;
ALCossListFree(cur);
ALCossListPopulate(NULL, cur);
while (cur != NULL)
{
AppendCaptureDeviceList(cur->handle);
cur = cur->next;
}
}
break;
}
+1
View File
@@ -22,6 +22,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
+4 -6
View File
@@ -56,16 +56,14 @@ static const ALubyte SUBTYPE_BFORMAT_FLOAT[] = {
static void fwrite16le(ALushort val, FILE *f)
{
fputc(val&0xff, f);
fputc((val>>8)&0xff, f);
ALubyte data[2] = { val&0xff, (val>>8)&0xff };
fwrite(data, 1, 2, f);
}
static void fwrite32le(ALuint val, FILE *f)
{
fputc(val&0xff, f);
fputc((val>>8)&0xff, f);
fputc((val>>16)&0xff, f);
fputc((val>>24)&0xff, f);
ALubyte data[4] = { val&0xff, (val>>8)&0xff, (val>>16)&0xff, (val>>24)&0xff };
fwrite(data, 1, 4, f);
}
+9 -11
View File
@@ -37,7 +37,7 @@
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
#endif
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
static vector_al_string PlaybackDevices;
@@ -71,13 +71,12 @@ static void ProbePlaybackDevices(void)
ALuint count = 0;
while(1)
{
al_string_copy_wcstr(&dname, WaveCaps.szPname);
if(count == 0)
al_string_append_cstr(&dname, DEVNAME_TAIL);
else
al_string_copy_cstr(&dname, DEVNAME_HEAD);
al_string_append_wcstr(&dname, WaveCaps.szPname);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&dname, str);
}
count++;
@@ -115,13 +114,12 @@ static void ProbeCaptureDevices(void)
ALuint count = 0;
while(1)
{
al_string_copy_wcstr(&dname, WaveCaps.szPname);
if(count == 0)
al_string_append_cstr(&dname, DEVNAME_TAIL);
else
al_string_copy_cstr(&dname, DEVNAME_HEAD);
al_string_append_wcstr(&dname, WaveCaps.szPname);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&dname, str);
}
count++;
+12 -12
View File
@@ -92,6 +92,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
for(it = 0;it < td;it++)
{
ALfloat smp = SamplesIn[it+base];
ALfloat a[3], b[3];
ALfloat alpha, w0;
ALfloat amplitude;
ALfloat cutoff;
@@ -117,19 +118,18 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
/* FIXME: Resonance controls the resonant peak, or Q. How? Not sure
* that Q = resonance*0.1. */
alpha = sinf(w0) / (2.0f * state->Resonance*0.1f);
state->LowPass.b[0] = (1.0f - cosf(w0)) / 2.0f;
state->LowPass.b[1] = 1.0f - cosf(w0);
state->LowPass.b[2] = (1.0f - cosf(w0)) / 2.0f;
state->LowPass.a[0] = 1.0f + alpha;
state->LowPass.a[1] = -2.0f * cosf(w0);
state->LowPass.a[2] = 1.0f - alpha;
b[0] = (1.0f - cosf(w0)) / 2.0f;
b[1] = 1.0f - cosf(w0);
b[2] = (1.0f - cosf(w0)) / 2.0f;
a[0] = 1.0f + alpha;
a[1] = -2.0f * cosf(w0);
a[2] = 1.0f - alpha;
state->LowPass.b[2] /= state->LowPass.a[0];
state->LowPass.b[1] /= state->LowPass.a[0];
state->LowPass.b[0] /= state->LowPass.a[0];
state->LowPass.a[2] /= state->LowPass.a[0];
state->LowPass.a[1] /= state->LowPass.a[0];
state->LowPass.a[0] /= state->LowPass.a[0];
state->LowPass.a1 = a[1] / a[0];
state->LowPass.a2 = a[2] / a[0];
state->LowPass.b1 = b[1] / a[0];
state->LowPass.b2 = b[2] / a[0];
state->LowPass.input_gain = b[0] / a[0];
temps[it] = ALfilterState_processSingle(&state->LowPass, smp);
}
+1 -1
View File
@@ -86,7 +86,7 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo
continue;
for(i = 0;i < SamplesToDo;i++)
SamplesOut[c][i] = SamplesIn[i] * gains[c];
SamplesOut[c][i] += SamplesIn[i] * gains[c];
}
}
+5 -6
View File
@@ -142,12 +142,11 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device
cw = cosf(F_TAU * Slot->EffectProps.Modulator.HighPassCutoff / Device->Frequency);
a = (2.0f-cw) - sqrtf(powf(2.0f-cw, 2.0f) - 1.0f);
state->Filter.b[0] = a;
state->Filter.b[1] = -a;
state->Filter.b[2] = 0.0f;
state->Filter.a[0] = 1.0f;
state->Filter.a[1] = -a;
state->Filter.a[2] = 0.0f;
state->Filter.a1 = -a;
state->Filter.a2 = 0.0f;
state->Filter.b1 = -a;
state->Filter.b2 = 0.0f;
state->Filter.input_gain = a;
ComputeAmbientGains(Device, Slot->Gain, state->Gain);
}
+161 -28
View File
@@ -364,6 +364,11 @@ void RestoreFPUMode(const FPUCtl *ctl)
}
static int StringSortCompare(const void *str1, const void *str2)
{
return al_string_cmp(*(const_al_string*)str1, *(const_al_string*)str2);
}
#ifdef _WIN32
static WCHAR *FromUTF8(const char *str)
@@ -549,6 +554,13 @@ FILE *OpenDataFile(const char *fname, const char *subdir)
}
static size_t strlenW(const WCHAR *str)
{
const WCHAR *end = str;
while(*end) ++end;
return end-str;
}
static const WCHAR *strchrW(const WCHAR *str, WCHAR ch)
{
for(;*str != 0;++str)
@@ -570,9 +582,27 @@ static const WCHAR *strrchrW(const WCHAR *str, WCHAR ch)
return ret;
}
static const WCHAR *strstrW(const WCHAR *haystack, const WCHAR *needle)
{
size_t len = strlenW(needle);
while(*haystack != 0)
{
if(CompareStringW(GetThreadLocale(), NORM_IGNORECASE,
haystack, len, needle, len) == CSTR_EQUAL)
return haystack;
do {
++haystack;
} while(((*haystack)&0xC000) == 0x8000);
}
return NULL;
}
/* Compares the filename in the find data with the match string. The match
* string may contain the "%r" marker to signifiy a sample rate (really any
* positive integer), or "%%" to signify a single '%'.
* positive integer), "%%" to signify a single '%', or "%s" for a (non-greedy)
* string.
*/
static int MatchFilter(const WCHAR *match, const WIN32_FIND_DATAW *fdata)
{
@@ -608,6 +638,40 @@ static int MatchFilter(const WCHAR *match, const WIN32_FIND_DATAW *fdata)
ret = l > 0;
++p;
}
else if(*p == 's')
{
const WCHAR *next = p+1;
if(*next != '\0' && *next != '%')
{
const WCHAR *next_p = strchrW(next, '%');
const WCHAR *m;
if(!next_p)
m = strstrW(name, next);
else
{
WCHAR *tmp = malloc((next_p - next + 1) * 2);
memcpy(tmp, next, (next_p - next) * 2);
tmp[next_p - next] = 0;
m = strstrW(name, tmp);
free(tmp);
}
ret = !!m;
if(ret)
{
size_t l;
if(next_p) l = next_p - next;
else l = strlenW(next);
name = m + l;
next += l;
}
}
p = next;
}
}
}
@@ -647,6 +711,7 @@ static void RecurseDirectorySearch(const char *path, const WCHAR *match, vector_
hdl = FindFirstFileW(wpath, &fdata);
if(hdl != INVALID_HANDLE_VALUE)
{
size_t base = VECTOR_SIZE(*results);
do {
if(MatchFilter(match, &fdata))
{
@@ -659,6 +724,10 @@ static void RecurseDirectorySearch(const char *path, const WCHAR *match, vector_
}
} while(FindNextFileW(hdl, &fdata));
FindClose(hdl);
if(VECTOR_SIZE(*results) > base)
qsort(VECTOR_ITER_BEGIN(*results)+base, VECTOR_SIZE(*results)-base,
sizeof(VECTOR_FRONT(*results)), StringSortCompare);
}
free(wpath);
@@ -785,8 +854,17 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir)
al_string path = AL_STRING_INIT_STATIC();
WCHAR *cwdbuf;
/* Search the CWD. */
if(!(cwdbuf=_wgetcwd(NULL, 0)))
/* Search the app-local directory. */
if((cwdbuf=_wgetenv(L"ALSOFT_LOCAL_PATH")) && *cwdbuf != '\0')
{
al_string_copy_wcstr(&path, cwdbuf);
if(is_slash(VECTOR_BACK(path)))
{
VECTOR_POP_BACK(path);
*VECTOR_ITER_END(path) = 0;
}
}
else if(!(cwdbuf=_wgetcwd(NULL, 0)))
al_string_copy_cstr(&path, ".");
else
{
@@ -798,6 +876,9 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir)
}
free(cwdbuf);
}
#define FIX_SLASH(i) do { if(*(i) == '/') *(i) = '\\'; } while(0)
VECTOR_FOR_EACH(char, path, FIX_SLASH);
#undef FIX_SLASH
RecurseDirectorySearch(al_string_get_cstr(path), wmatch, &results);
/* Search the local and global data dirs. */
@@ -945,11 +1026,8 @@ FILE *OpenDataFile(const char *fname, const char *subdir)
}
static const char *MatchString;
static int MatchFilter(const struct dirent *dir)
static int MatchFilter(const char *name, const char *match)
{
const char *match = MatchString;
const char *name = dir->d_name;
int ret = 1;
do {
@@ -973,6 +1051,40 @@ static int MatchFilter(const struct dirent *dir)
if(ret) name = end;
++p;
}
else if(*p == 's')
{
const char *next = p+1;
if(*next != '\0' && *next != '%')
{
const char *next_p = strchr(next, '%');
const char *m;
if(!next_p)
m = strstr(name, next);
else
{
char *tmp = malloc(next_p - next + 1);
memcpy(tmp, next, next_p - next);
tmp[next_p - next] = 0;
m = strstr(name, tmp);
free(tmp);
}
ret = !!m;
if(ret)
{
size_t l;
if(next_p) l = next_p - next;
else l = strlen(next);
name = m + l;
next += l;
}
}
p = next;
}
}
}
@@ -984,9 +1096,7 @@ static int MatchFilter(const struct dirent *dir)
static void RecurseDirectorySearch(const char *path, const char *match, vector_al_string *results)
{
struct dirent **namelist;
char *sep, *p;
int n, i;
if(!match[0])
return;
@@ -996,22 +1106,33 @@ static void RecurseDirectorySearch(const char *path, const char *match, vector_a
if(!sep)
{
MatchString = match;
DIR *dir;
TRACE("Searching %s for %s\n", path?path:"/", match);
n = scandir(path?path:"/", &namelist, MatchFilter, alphasort);
if(n >= 0)
dir = opendir(path?path:"/");
if(dir != NULL)
{
for(i = 0;i < n;++i)
size_t base = VECTOR_SIZE(*results);
struct dirent *dirent;
while((dirent=readdir(dir)) != NULL)
{
al_string str = AL_STRING_INIT_STATIC();
al_string str;
if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0 ||
!MatchFilter(dirent->d_name, match))
continue;
AL_STRING_INIT(str);
if(path) al_string_copy_cstr(&str, path);
al_string_append_char(&str, '/');
al_string_append_cstr(&str, namelist[i]->d_name);
al_string_append_cstr(&str, dirent->d_name);
TRACE("Got result %s\n", al_string_get_cstr(str));
VECTOR_PUSH_BACK(*results, str);
free(namelist[i]);
}
free(namelist);
closedir(dir);
if(VECTOR_SIZE(*results) > base)
qsort(VECTOR_ITER_BEGIN(*results)+base, VECTOR_SIZE(*results)-base,
sizeof(VECTOR_FRONT(*results)), StringSortCompare);
}
return;
@@ -1040,11 +1161,13 @@ static void RecurseDirectorySearch(const char *path, const char *match, vector_a
{
al_string npath = AL_STRING_INIT_STATIC();
al_string nmatch = AL_STRING_INIT_STATIC();
const char *tomatch;
DIR *dir;
if(!sep)
{
al_string_append_cstr(&npath, path?path:"/.");
MatchString = match;
tomatch = match;
}
else
{
@@ -1053,25 +1176,30 @@ static void RecurseDirectorySearch(const char *path, const char *match, vector_a
al_string_append_range(&npath, match, sep);
al_string_append_range(&nmatch, sep+1, next);
MatchString = al_string_get_cstr(nmatch);
tomatch = al_string_get_cstr(nmatch);
}
TRACE("Searching %s for %s\n", al_string_get_cstr(npath), MatchString);
n = scandir(al_string_get_cstr(npath), &namelist, MatchFilter, alphasort);
if(n >= 0)
TRACE("Searching %s for %s\n", al_string_get_cstr(npath), tomatch);
dir = opendir(path?path:"/");
if(dir != NULL)
{
al_string ndir = AL_STRING_INIT_STATIC();
for(i = 0;i < n;++i)
struct dirent *dirent;
while((dirent=readdir(dir)) != NULL)
{
if(strcmp(dirent->d_name, ".") == 0 || strcmp(dirent->d_name, "..") == 0 ||
!MatchFilter(dirent->d_name, tomatch))
continue;
al_string_copy(&ndir, npath);
al_string_append_char(&ndir, '/');
al_string_append_cstr(&ndir, namelist[i]->d_name);
free(namelist[i]);
al_string_append_cstr(&ndir, dirent->d_name);
TRACE("Recursing %s with %s\n", al_string_get_cstr(ndir), next+1);
RecurseDirectorySearch(al_string_get_cstr(ndir), next+1, results);
}
closedir(dir);
al_string_deinit(&ndir);
free(namelist);
}
al_string_deinit(&nmatch);
@@ -1099,8 +1227,13 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir)
const char *str, *next;
char cwdbuf[PATH_MAX];
// Search CWD
if(!getcwd(cwdbuf, sizeof(cwdbuf)))
/* Search the app-local directory. */
if((str=getenv("ALSOFT_LOCAL_PATH")) && *str != '\0')
{
strncpy(cwdbuf, str, sizeof(cwdbuf)-1);
cwdbuf[sizeof(cwdbuf)-1] = '\0';
}
else if(!getcwd(cwdbuf, sizeof(cwdbuf)))
strcpy(cwdbuf, ".");
RecurseDirectorySearch(cwdbuf, match, &results);
+1 -1
View File
@@ -820,7 +820,7 @@ error:
vector_HrtfEntry EnumerateHrtf(const_al_string devname)
{
vector_HrtfEntry list = VECTOR_INIT_STATIC();
const char *fnamelist = "default-%r.mhr";
const char *fnamelist = "%s.mhr";
ConfigValueStr(al_string_get_cstr(devname), NULL, "hrtf_tables", &fnamelist);
while(fnamelist && *fnamelist)