aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-06-03 09:40:30 -0700
committerChris Robinson <[email protected]>2016-06-03 09:40:30 -0700
commit2c402e1ab524532020b36426375098c39df0e9d8 (patch)
treee2d4ce5dec9042ce3ef3e796060e8e0e3f653b25
parente38a81c5b62a350e448f31fd482d92c61fd84c58 (diff)
Add property queries to get the device latency with the clock
-rw-r--r--Alc/ALc.c43
-rw-r--r--OpenAL32/Include/alMain.h2
2 files changed, 34 insertions, 11 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index d41aa0d4..7f42cb72 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2902,6 +2902,7 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname,
}
else /* render device */
{
+ ClockLatency clock;
ALuint64 basecount;
ALuint samplecount;
ALuint refcount;
@@ -2909,16 +2910,15 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname,
switch(pname)
{
case ALC_ATTRIBUTES_SIZE:
- *values = 19;
+ *values = 21;
break;
case ALC_ALL_ATTRIBUTES:
- if(size < 19)
+ if(size < 21)
alcSetError(device, ALC_INVALID_VALUE);
else
{
- int i = 0;
-
+ i = 0;
almtx_lock(&device->BackendLock);
values[i++] = ALC_FREQUENCY;
values[i++] = device->Frequency;
@@ -2955,14 +2955,12 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname,
values[i++] = ALC_HRTF_STATUS_SOFT;
values[i++] = device->Hrtf_Status;
+ clock = V0(device->Backend,getClockLatency)();
values[i++] = ALC_DEVICE_CLOCK_SOFT;
- do {
- while(((refcount=ReadRef(&device->MixCount))&1) != 0)
- althrd_yield();
- basecount = device->ClockBase;
- samplecount = device->SamplesDone;
- } while(refcount != ReadRef(&device->MixCount));
- values[i++] = basecount + (samplecount*DEVICE_CLOCK_RES/device->Frequency);
+ values[i++] = clock.ClockTime;
+
+ values[i++] = ALC_DEVICE_LATENCY_SOFT;
+ values[i++] = clock.Latency;
almtx_unlock(&device->BackendLock);
values[i++] = 0;
@@ -2981,6 +2979,29 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname,
almtx_unlock(&device->BackendLock);
break;
+ case ALC_DEVICE_LATENCY_SOFT:
+ {
+ almtx_lock(&device->BackendLock);
+ clock = V0(device->Backend,getClockLatency)();
+ almtx_unlock(&device->BackendLock);
+ *values = clock.Latency;
+ }
+ break;
+
+ case ALC_DEVICE_CLOCK_LATENCY_SOFT:
+ if(size < 2)
+ alcSetError(device, ALC_INVALID_VALUE);
+ else
+ {
+ ClockLatency clock;
+ almtx_lock(&device->BackendLock);
+ clock = V0(device->Backend,getClockLatency)();
+ almtx_unlock(&device->BackendLock);
+ values[0] = clock.ClockTime;
+ values[1] = clock.Latency;
+ }
+ break;
+
default:
ivals = malloc(size * sizeof(ALCint));
size = GetIntegerv(device, pname, size, ivals);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 18aa4df3..ed4e56f2 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -46,6 +46,8 @@
typedef int64_t ALCint64SOFT;
typedef uint64_t ALCuint64SOFT;
#define ALC_DEVICE_CLOCK_SOFT 0x1600
+#define ALC_DEVICE_LATENCY_SOFT 0x1601
+#define ALC_DEVICE_CLOCK_LATENCY_SOFT 0x1602
typedef void (ALC_APIENTRY*LPALCGETINTEGER64VSOFT)(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values);
#ifdef AL_ALEXT_PROTOTYPES
ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values);