diff options
author | Chris Robinson <[email protected]> | 2015-02-03 01:08:38 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-02-03 01:08:38 -0800 |
commit | e53861bfb9fe76be20c696660cb5825f2efc9675 (patch) | |
tree | dbd0e0cc51ef6c78605e87a02c2c78837f42e8e8 | |
parent | 290badea95fb7a971fbf6efdf792cc322128098a (diff) |
Always use the JACK server buffer size as the update size
The buffer-size config option now only specifies an additional mix ahead to
keep ready for audio requests, rather than a pretend period size.
-rw-r--r-- | Alc/backends/jack.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index 05de5528..8d57e7d3 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -202,15 +202,17 @@ static int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg) ALuint bufsize; ALCjackPlayback_lock(self); - if(ConfigValueUInt("jack", "buffer-size", &bufsize)) - device->UpdateSize = maxu(numframes, NextPowerOf2(bufsize)); - else - device->UpdateSize = numframes; + device->UpdateSize = numframes; + device->NumUpdates = 2; TRACE("%u update size x%u\n", device->UpdateSize, device->NumUpdates); + bufsize = device->UpdateSize; + if(ConfigValueUInt("jack", "buffer-size", &bufsize)) + bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); + bufsize += device->UpdateSize; + ll_ringbuffer_free(self->Ring); - self->Ring = ll_ringbuffer_create(device->UpdateSize * device->NumUpdates, - FrameSizeFromDevFmt(device->FmtChans, device->FmtType)); + self->Ring = ll_ringbuffer_create(bufsize, FrameSizeFromDevFmt(device->FmtChans, device->FmtType)); if(!self->Ring) { ERR("Failed to reallocate ringbuffer\n"); @@ -377,12 +379,14 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) * because there's one element less of it that's writeable, and we only * write in update-sized chunks. */ device->Frequency = jack_get_sample_rate(self->Client); - if(ConfigValueUInt("jack", "buffer-size", &bufsize)) - device->UpdateSize = maxu(jack_get_buffer_size(self->Client), NextPowerOf2(bufsize)); - else - device->UpdateSize = jack_get_buffer_size(self->Client); + device->UpdateSize = jack_get_buffer_size(self->Client); device->NumUpdates = 2; + bufsize = device->UpdateSize; + if(ConfigValueUInt("jack", "buffer-size", &bufsize)) + bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); + bufsize += device->UpdateSize; + /* Force 32-bit float output. */ device->FmtType = DevFmtFloat; @@ -415,8 +419,7 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) } ll_ringbuffer_free(self->Ring); - self->Ring = ll_ringbuffer_create(device->UpdateSize * device->NumUpdates, - FrameSizeFromDevFmt(device->FmtChans, device->FmtType)); + self->Ring = ll_ringbuffer_create(bufsize, FrameSizeFromDevFmt(device->FmtChans, device->FmtType)); if(!self->Ring) { ERR("Failed to allocate ringbuffer\n"); |