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 | |
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')
-rw-r--r-- | Alc/backends/alsa.c | 2 | ||||
-rw-r--r-- | Alc/backends/coreaudio.c | 2 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 2 | ||||
-rw-r--r-- | Alc/backends/jack.c | 10 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 2 | ||||
-rw-r--r-- | Alc/backends/opensl.c | 12 | ||||
-rw-r--r-- | Alc/backends/oss.c | 2 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 2 |
8 files changed, 13 insertions, 21 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index d0f0e24e..9fc36582 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -1123,7 +1123,7 @@ static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name) if(needring) { self->ring = ll_ringbuffer_create( - device->UpdateSize*device->NumUpdates + 1, + device->UpdateSize*device->NumUpdates, FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder), false ); diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index caa01167..b2545c47 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -663,7 +663,7 @@ static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar goto error; self->ring = ll_ringbuffer_create( - device->UpdateSize*self->sampleRateRatio*device->NumUpdates + 1, + (size_t)ceil(device->UpdateSize*self->sampleRateRatio*device->NumUpdates), self->frameSize, false ); if(!self->ring) goto error; diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 4c52e0f8..6bab641c 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -856,7 +856,7 @@ static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *devi hr = IDirectSoundCapture_CreateCaptureBuffer(self->DSC, &DSCBDescription, &self->DSCbuffer, NULL); if(SUCCEEDED(hr)) { - self->Ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates + 1, + self->Ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates, InputType.Format.nBlockAlign, false); if(self->Ring == NULL) hr = DSERR_OUTOFMEMORY; 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; diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index 34dcf468..961cba52 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -1810,7 +1810,7 @@ static HRESULT ALCmmdevCapture_resetProxy(ALCmmdevCapture *self) return hr; } - buffer_len = maxu(device->UpdateSize*device->NumUpdates + 1, buffer_len); + buffer_len = maxu(device->UpdateSize*device->NumUpdates, buffer_len); ll_ringbuffer_free(self->Ring); self->Ring = ll_ringbuffer_create(buffer_len, FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder), diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c index d930526d..a5ad3b09 100644 --- a/Alc/backends/opensl.c +++ b/Alc/backends/opensl.c @@ -566,12 +566,8 @@ static ALCboolean ALCopenslPlayback_start(ALCopenslPlayback *self) SLresult result; ll_ringbuffer_free(self->mRing); - /* NOTE: Add an extra update since 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. - */ - self->mRing = ll_ringbuffer_create(device->NumUpdates + 1, - self->mFrameSize*device->UpdateSize, true); + self->mRing = ll_ringbuffer_create(device->NumUpdates, self->mFrameSize*device->UpdateSize, + true); result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue); @@ -847,8 +843,8 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name if(SL_RESULT_SUCCESS == result) { - self->mRing = ll_ringbuffer_create(device->NumUpdates + 1, - device->UpdateSize * self->mFrameSize, false); + self->mRing = ll_ringbuffer_create(device->NumUpdates, device->UpdateSize*self->mFrameSize, + false); result = VCALL(self->mRecordObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &bufferQueue); diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index 61d25476..c0c98c43 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -729,7 +729,7 @@ static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name) return ALC_INVALID_VALUE; } - self->ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates + 1, frameSize, false); + self->ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates, frameSize, false); if(!self->ring) { ERR("Ring buffer create failed\n"); diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 787ba8e4..2f4c65df 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -626,7 +626,7 @@ static ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *name) if(CapturedDataSize < (self->Format.nSamplesPerSec / 10)) CapturedDataSize = self->Format.nSamplesPerSec / 10; - self->Ring = ll_ringbuffer_create(CapturedDataSize+1, self->Format.nBlockAlign, false); + self->Ring = ll_ringbuffer_create(CapturedDataSize, self->Format.nBlockAlign, false); if(!self->Ring) goto failure; InitRef(&self->WaveBuffersCommitted, 0); |