aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/opensl.c
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/opensl.c
parentcba37819d1e68ff6473d0e10b42ac9465943d5cb (diff)
Add an option to limit the write size of the ringbuffer
Diffstat (limited to 'Alc/backends/opensl.c')
-rw-r--r--Alc/backends/opensl.c16
1 files changed, 5 insertions, 11 deletions
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);