aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-01 21:23:13 -0800
committerChris Robinson <[email protected]>2018-03-01 21:23:13 -0800
commit6f62fed65c4dcdf999a612e258cca59a22355f3c (patch)
treebd8d8f9e84beb94761ae35da41c3e66465af62a8 /Alc/backends
parentcba37819d1e68ff6473d0e10b42ac9465943d5cb (diff)
Add an option to limit the write size of the ringbuffer
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c3
-rw-r--r--Alc/backends/coreaudio.c2
-rw-r--r--Alc/backends/dsound.c2
-rw-r--r--Alc/backends/jack.c6
-rw-r--r--Alc/backends/mmdevapi.c3
-rw-r--r--Alc/backends/opensl.c16
-rw-r--r--Alc/backends/oss.c2
-rw-r--r--Alc/backends/portaudio.c2
-rw-r--r--Alc/backends/winmm.c2
9 files changed, 18 insertions, 20 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index c75749de..d0f0e24e 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -1124,7 +1124,8 @@ static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name)
{
self->ring = ll_ringbuffer_create(
device->UpdateSize*device->NumUpdates + 1,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder)
+ FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder),
+ false
);
if(!self->ring)
{
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c
index 3db0d702..caa01167 100644
--- a/Alc/backends/coreaudio.c
+++ b/Alc/backends/coreaudio.c
@@ -664,7 +664,7 @@ static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar
self->ring = ll_ringbuffer_create(
device->UpdateSize*self->sampleRateRatio*device->NumUpdates + 1,
- self->frameSize
+ self->frameSize, false
);
if(!self->ring) goto error;
diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c
index 0040a840..4c52e0f8 100644
--- a/Alc/backends/dsound.c
+++ b/Alc/backends/dsound.c
@@ -857,7 +857,7 @@ static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *devi
if(SUCCEEDED(hr))
{
self->Ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates + 1,
- InputType.Format.nBlockAlign);
+ InputType.Format.nBlockAlign, false);
if(self->Ring == NULL)
hr = DSERR_OUTOFMEMORY;
}
diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c
index e6f4b435..003877a4 100644
--- a/Alc/backends/jack.c
+++ b/Alc/backends/jack.c
@@ -236,7 +236,8 @@ static int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg)
ll_ringbuffer_free(self->Ring);
self->Ring = ll_ringbuffer_create(bufsize,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder)
+ FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder),
+ true
);
if(!self->Ring)
{
@@ -437,7 +438,8 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self)
ll_ringbuffer_free(self->Ring);
self->Ring = ll_ringbuffer_create(bufsize,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder)
+ FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder),
+ true
);
if(!self->Ring)
{
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 5f1dbba8..34dcf468 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -1813,7 +1813,8 @@ static HRESULT ALCmmdevCapture_resetProxy(ALCmmdevCapture *self)
buffer_len = maxu(device->UpdateSize*device->NumUpdates + 1, buffer_len);
ll_ringbuffer_free(self->Ring);
self->Ring = ll_ringbuffer_create(buffer_len,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder)
+ FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder),
+ false
);
if(!self->Ring)
{
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index b20d7841..d930526d 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -239,7 +239,6 @@ static int ALCopenslPlayback_mixerProc(void *arg)
ll_ringbuffer_data_t data[2];
SLPlayItf player;
SLresult result;
- size_t padding;
SetRTPriority();
althrd_setname(althrd_current(), MIXER_THREAD_NAME);
@@ -260,18 +259,13 @@ static int ALCopenslPlayback_mixerProc(void *arg)
return 1;
}
- /* NOTE: The ringbuffer will be larger than the desired buffer metrics.
- * Calculate the amount of extra space so we know how much to keep unused.
- */
- padding = ll_ringbuffer_write_space(self->mRing) - device->NumUpdates;
-
ALCopenslPlayback_lock(self);
while(!ATOMIC_LOAD(&self->mKillNow, almemory_order_acquire) &&
ATOMIC_LOAD(&device->Connected, almemory_order_acquire))
{
size_t todo, len0, len1;
- if(ll_ringbuffer_write_space(self->mRing) <= padding)
+ if(ll_ringbuffer_write_space(self->mRing) == 0)
{
SLuint32 state = 0;
@@ -288,7 +282,7 @@ static int ALCopenslPlayback_mixerProc(void *arg)
break;
}
- if(ll_ringbuffer_write_space(self->mRing) <= padding)
+ if(ll_ringbuffer_write_space(self->mRing) == 0)
{
ALCopenslPlayback_unlock(self);
alsem_wait(&self->mSem);
@@ -298,7 +292,7 @@ static int ALCopenslPlayback_mixerProc(void *arg)
}
ll_ringbuffer_get_write_vector(self->mRing, data);
- todo = data[0].len+data[1].len - padding;
+ todo = data[0].len+data[1].len;
len0 = minu(todo, data[0].len);
len1 = minu(todo-len0, data[1].len);
@@ -577,7 +571,7 @@ static ALCboolean ALCopenslPlayback_start(ALCopenslPlayback *self)
* 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);
+ self->mFrameSize*device->UpdateSize, true);
result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue);
@@ -854,7 +848,7 @@ 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);
+ 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 faf3ee99..61d25476 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);
+ self->ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates + 1, frameSize, false);
if(!self->ring)
{
ERR("Ring buffer create failed\n");
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index fdc8a2a5..9b0d3487 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -395,7 +395,7 @@ static ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name)
samples = maxu(samples, 100 * device->Frequency / 1000);
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
- self->ring = ll_ringbuffer_create(samples, frame_size);
+ self->ring = ll_ringbuffer_create(samples, frame_size, false);
if(self->ring == NULL) return ALC_INVALID_VALUE;
self->params.device = -1;
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index d6ecd7a9..787ba8e4 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);
+ self->Ring = ll_ringbuffer_create(CapturedDataSize+1, self->Format.nBlockAlign, false);
if(!self->Ring) goto failure;
InitRef(&self->WaveBuffersCommitted, 0);