Merge pull request #3441 from Sonicadvance1/opensles_audio_delay
[OpenSLES] Fix a delay in audio processing.
This commit is contained in:
commit
465ef93beb
|
@ -37,19 +37,15 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
assert(bq == bqPlayerBufferQueue);
|
assert(bq == bqPlayerBufferQueue);
|
||||||
assert(nullptr == context);
|
assert(nullptr == context);
|
||||||
|
|
||||||
short *nextBuffer = buffer[curBuffer];
|
// Render to the fresh buffer
|
||||||
int nextSize = sizeof(buffer[0]);
|
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
||||||
|
SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[0]));
|
||||||
SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
|
curBuffer ^= 1; // Switch buffer
|
||||||
|
|
||||||
// Comment from sample code:
|
// Comment from sample code:
|
||||||
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
|
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
|
||||||
// which for this code example would indicate a programming error
|
// which for this code example would indicate a programming error
|
||||||
_assert_msg_(AUDIO, SL_RESULT_SUCCESS == result, "Couldn't enqueue audio stream.");
|
_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()
|
bool OpenSLESStream::Start()
|
||||||
|
|
Loading…
Reference in New Issue