summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/OpenSLESStream.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2016-01-03 11:29:55 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2016-01-03 11:33:38 -0600
commit1db01a8c56b6758c81ff4c3fa9e39edab25fab89 (patch)
tree821bd2d74f9deffcd5b7e4eee20400694360ca25 /Source/Core/AudioCommon/OpenSLESStream.cpp
parenta63873535fd0e63d53d1ca3ad76061dd01929b0e (diff)
[OpenSLES] Fix a delay in audio processing.
A failure on my part. I was updating the two buffers in the wrong order, so we were always a buffer behind in sending audio out to OpenSLES.
Diffstat (limited to 'Source/Core/AudioCommon/OpenSLESStream.cpp')
-rw-r--r--Source/Core/AudioCommon/OpenSLESStream.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/OpenSLESStream.cpp b/Source/Core/AudioCommon/OpenSLESStream.cpp
index e8b5ff0335..9c02338fa5 100644
--- a/Source/Core/AudioCommon/OpenSLESStream.cpp
+++ b/Source/Core/AudioCommon/OpenSLESStream.cpp
@@ -37,19 +37,15 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
assert(bq == bqPlayerBufferQueue);
assert(nullptr == context);
- short *nextBuffer = buffer[curBuffer];
- int nextSize = sizeof(buffer[0]);
-
- SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
+ // Render to the fresh buffer
+ g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
+ SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[0]));
+ curBuffer ^= 1; // Switch buffer
// Comment from sample code:
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
// which for this code example would indicate a programming error
_assert_msg_(AUDIO, SL_RESULT_SUCCESS == result, "Couldn't enqueue audio stream.");
-
- curBuffer ^= 1; // Switch buffer
- // Render to the fresh buffer
- g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
}
bool OpenSLESStream::Start()