Compare commits

...

7 Commits

Author SHA1 Message Date
Chris Robinson 1226aec2fc Don't change the format tag in MakeExtensible 2019-05-23 02:49:04 -07:00
Chris Robinson 99a55c4452 Handle a missing default WASAPI device ID
Backported fix from d1a86075 on master.
2019-02-20 00:22:19 -08:00
John Preston 14cf721094 Fix Resample_bsinc_SSE pointer casts.
Regression was introduced in 5ec11a017c.
2018-11-08 03:59:19 -08:00
Chris Robinson 515bc4ba53 Workaround lack of roundf with early MSVC 2018-11-02 19:16:45 -07:00
Chris Robinson 25dfe4b57a Use HUGE_VALF instead of INFINITY
Older MSVC lacks INFINITY, and we define a HUGE_VALF fallback when needed.
2018-11-02 19:16:26 -07:00
Chris Robinson 9a4a3d3977 Specify the correct array size for casting 2018-11-02 19:16:02 -07:00
alexey.lysiuk 4fd0cd3151 Use GCD semaphore on macOS
Unnamed POSIX semaphore doesn't work on macOS
2018-11-02 19:15:21 -07:00
5 changed files with 69 additions and 9 deletions
+9 -5
View File
@@ -328,7 +328,7 @@ static HRESULT probe_devices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, ve
devid = get_device_id(device);
if(devid)
{
if(wcscmp(devid, defdevid) != 0)
if(!defdevid || wcscmp(devid, defdevid) != 0)
add_device(device, devid, list);
CoTaskMemFree(devid);
}
@@ -695,12 +695,14 @@ static ALCboolean MakeExtensible(WAVEFORMATEXTENSIBLE *out, const WAVEFORMATEX *
{
memset(out, 0, sizeof(*out));
if(in->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
*out = *(const WAVEFORMATEXTENSIBLE*)in;
out->Format.cbSize = sizeof(*out) - sizeof(out->Format);
}
else if(in->wFormatTag == WAVE_FORMAT_PCM)
{
out->Format = *in;
out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
out->Format.cbSize = sizeof(*out) - sizeof(*in);
out->Format.cbSize = 0;
if(out->Format.nChannels == 1)
out->dwChannelMask = MONO;
else if(out->Format.nChannels == 2)
@@ -712,8 +714,7 @@ static ALCboolean MakeExtensible(WAVEFORMATEXTENSIBLE *out, const WAVEFORMATEX *
else if(in->wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
{
out->Format = *in;
out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
out->Format.cbSize = sizeof(*out) - sizeof(*in);
out->Format.cbSize = 0;
if(out->Format.nChannels == 1)
out->dwChannelMask = MONO;
else if(out->Format.nChannels == 2)
@@ -938,6 +939,7 @@ static HRESULT ALCwasapiPlayback_resetProxy(ALCwasapiPlayback *self)
ERR("Unhandled channel config: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask);
}
OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
switch(device->FmtChans)
{
case DevFmtMono:
@@ -1079,6 +1081,8 @@ static HRESULT ALCwasapiPlayback_resetProxy(ALCwasapiPlayback *self)
{
ERR("Unhandled format sub-type\n");
device->FmtType = DevFmtShort;
if(OutputType.Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE)
OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
OutputType.Format.wBitsPerSample = 16;
OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
}
+16 -3
View File
@@ -6,6 +6,19 @@
#include "alu.h"
#include "almalloc.h"
#include "static_assert.h"
#include "math_defs.h"
/* Early MSVC lacks round/roundf */
#if defined(_MSC_VER) && _MSC_VER < 1800
static double round(double val)
{
if(val < 0.0)
return ceil(val-0.5);
return floor(val+0.5);
}
#define roundf(f) ((float)round((float)(f)))
#endif
/* These structures assume BUFFERSIZE is a power of 2. */
@@ -463,14 +476,14 @@ Compressor* CompressorInit(const ALsizei NumChans, const ALuint SampleRate,
if(hold > 0)
{
Comp->Hold = (SlidingHold*)(Comp + 1);
Comp->Hold->Values[0] = -INFINITY;
Comp->Hold->Values[0] = -HUGE_VALF;
Comp->Hold->Expiries[0] = hold;
Comp->Hold->Length = hold;
Comp->Delay = (ALfloat(*)[])(Comp->Hold + 1);
Comp->Delay = (ALfloat(*)[BUFFERSIZE])(Comp->Hold + 1);
}
else
{
Comp->Delay = (ALfloat(*)[])(Comp + 1);
Comp->Delay = (ALfloat(*)[BUFFERSIZE])(Comp + 1);
}
}
+1 -1
View File
@@ -402,7 +402,7 @@ int main()
IF(HAVE___BUILTIN_ASSUME_ALIGNED)
SET(ASSUME_ALIGNED_DECL "__builtin_assume_aligned(x, y)")
ELSE()
SET(ASSUME_ALIGNED_DECL "x")
SET(ASSUME_ALIGNED_DECL "(x)")
ENDIF()
SET(SSE_SWITCH "")
+35
View File
@@ -631,6 +631,39 @@ void alcnd_destroy(alcnd_t *cond)
}
#ifdef __APPLE__
int alsem_init(alsem_t *sem, unsigned int initial)
{
*sem = dispatch_semaphore_create(initial);
return *sem ? althrd_success : althrd_error;
}
void alsem_destroy(alsem_t *sem)
{
dispatch_release(*sem);
}
int alsem_post(alsem_t *sem)
{
dispatch_semaphore_signal(*sem);
return althrd_success;
}
int alsem_wait(alsem_t *sem)
{
dispatch_semaphore_wait(*sem, DISPATCH_TIME_FOREVER);
return althrd_success;
}
int alsem_trywait(alsem_t *sem)
{
long value = dispatch_semaphore_wait(*sem, DISPATCH_TIME_NOW);
return value == 0 ? althrd_success : althrd_busy;
}
#else /* !__APPLE__ */
int alsem_init(alsem_t *sem, unsigned int initial)
{
if(sem_init(sem, 0, initial) == 0)
@@ -665,6 +698,8 @@ int alsem_trywait(alsem_t *sem)
return althrd_error;
}
#endif /* __APPLE__ */
int altss_create(altss_t *tss_id, altss_dtor_t callback)
{
+8
View File
@@ -130,13 +130,21 @@ inline int altss_set(altss_t tss_id, void *val)
#include <stdint.h>
#include <errno.h>
#include <pthread.h>
#ifdef __APPLE__
#include <dispatch/dispatch.h>
#else /* !__APPLE__ */
#include <semaphore.h>
#endif /* __APPLE__ */
typedef pthread_t althrd_t;
typedef pthread_mutex_t almtx_t;
typedef pthread_cond_t alcnd_t;
#ifdef __APPLE__
typedef dispatch_semaphore_t alsem_t;
#else /* !__APPLE__ */
typedef sem_t alsem_t;
#endif /* __APPLE__ */
typedef pthread_key_t altss_t;
typedef pthread_once_t alonce_flag;