diff options
author | Chris Robinson <[email protected]> | 2014-12-23 11:42:57 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-12-23 11:42:57 -0800 |
commit | e84b3f4707dc24a33826934966b1201811e8057a (patch) | |
tree | 1d9eac013801f7ee5d7a8b7941b52a10886a8a75 /Alc/backends | |
parent | beb670a93966973fa9b8b9902599e37cae9139bb (diff) |
At least measure the ringbuffer size for JACK's latency
We should also add the port latency, but there's currently no way to ensure
it's synchronized with the ringbuffer (the ringbuffer will update before the
port latency gets updated).
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/jack.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index f4d4e181..9597f8af 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -59,6 +59,7 @@ static const ALCchar jackDevice[] = "JACK Default"; MAGIC(jack_ringbuffer_get_read_vector); \ MAGIC(jack_ringbuffer_get_write_vector); \ MAGIC(jack_ringbuffer_read_advance); \ + MAGIC(jack_ringbuffer_read_space); \ MAGIC(jack_ringbuffer_write_advance); \ MAGIC(jack_ringbuffer_write_space); \ MAGIC(jack_set_process_callback); \ @@ -90,6 +91,7 @@ JACK_FUNCS(MAKE_FUNC); #define jack_ringbuffer_get_read_vector pjack_ringbuffer_get_read_vector #define jack_ringbuffer_get_write_vector pjack_ringbuffer_get_write_vector #define jack_ringbuffer_read_advance pjack_ringbuffer_read_advance +#define jack_ringbuffer_read_space pjack_ringbuffer_read_space #define jack_ringbuffer_write_advance pjack_ringbuffer_write_advance #define jack_ringbuffer_write_space pjack_ringbuffer_write_space #define jack_set_process_callback pjack_set_process_callback @@ -162,7 +164,7 @@ static ALCboolean ALCjackPlayback_start(ALCjackPlayback *self); static void ALCjackPlayback_stop(ALCjackPlayback *self); static DECLARE_FORWARD2(ALCjackPlayback, ALCbackend, ALCenum, captureSamples, void*, ALCuint) static DECLARE_FORWARD(ALCjackPlayback, ALCbackend, ALCuint, availableSamples) -static DECLARE_FORWARD(ALCjackPlayback, ALCbackend, ALint64, getLatency) +static ALint64 ALCjackPlayback_getLatency(ALCjackPlayback *self); static void ALCjackPlayback_lock(ALCjackPlayback *self); static void ALCjackPlayback_unlock(ALCjackPlayback *self); DECLARE_DEFAULT_ALLOCATORS(ALCjackPlayback) @@ -488,6 +490,20 @@ static void ALCjackPlayback_stop(ALCjackPlayback *self) } +static ALint64 ALCjackPlayback_getLatency(ALCjackPlayback *self) +{ + ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; + ALint64 latency; + + ALCjackPlayback_lock(self); + latency = jack_ringbuffer_read_space(self->Ring) / + FrameSizeFromDevFmt(device->FmtChans, device->FmtType); + ALCjackPlayback_unlock(self); + + return latency * 1000000000 / device->Frequency; +} + + static void ALCjackPlayback_lock(ALCjackPlayback *self) { almtx_lock(&STATIC_CAST(ALCbackend,self)->mMutex); |