aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/jack.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends/jack.c')
-rw-r--r--Alc/backends/jack.c27
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");