diff options
author | Chris Robinson <[email protected]> | 2018-03-02 12:46:31 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-02 13:01:11 -0800 |
commit | 03274a5b95146675c05b5b6a0340f45a7b122c50 (patch) | |
tree | 02c6bec8667f888742c79a5538995e82797e2fd2 /Alc/backends/jack.c | |
parent | 6f62fed65c4dcdf999a612e258cca59a22355f3c (diff) |
Ensure at least the specified ringbuffer size is writable
Previously, all but one of the specified size could be written (so for a size
of n, only n-1 was guaranteed writable). All users pretty much compensated for
this, but it makes more sense to fix it at the source.
Diffstat (limited to 'Alc/backends/jack.c')
-rw-r--r-- | Alc/backends/jack.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index 003877a4..67e3c106 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -229,8 +229,7 @@ static int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg) bufsize = device->UpdateSize; if(ConfigValueUInt(alstr_get_cstr(device->DeviceName), "jack", "buffer-size", &bufsize)) bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); - bufsize += device->UpdateSize; - device->NumUpdates = bufsize / device->UpdateSize; + device->NumUpdates = (bufsize+device->UpdateSize) / device->UpdateSize; TRACE("%u update size x%u\n", device->UpdateSize, device->NumUpdates); @@ -391,9 +390,7 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) } /* Ignore the requested buffer metrics and just keep one JACK-sized buffer - * ready for when requested. Note that one period's worth of audio in the - * ring buffer will always be left unfilled because one element of the ring - * buffer will not be writeable, and we only write in period-sized chunks. + * ready for when requested. */ device->Frequency = jack_get_sample_rate(self->Client); device->UpdateSize = jack_get_buffer_size(self->Client); @@ -402,8 +399,7 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) bufsize = device->UpdateSize; if(ConfigValueUInt(alstr_get_cstr(device->DeviceName), "jack", "buffer-size", &bufsize)) bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); - bufsize += device->UpdateSize; - device->NumUpdates = bufsize / device->UpdateSize; + device->NumUpdates = (bufsize+device->UpdateSize) / device->UpdateSize; /* Force 32-bit float output. */ device->FmtType = DevFmtFloat; |