Merge pull request #1325 from Sonicadvance1/Android-OpenSLES-race
Fix a race condition in our OpenSL ES audio backend.
This commit is contained in:
commit
b769331f50
|
@ -45,7 +45,6 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
// 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
|
curBuffer ^= 1; // Switch buffer
|
||||||
// Render to the fresh buffer
|
// Render to the fresh buffer
|
||||||
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
g_mixer->Mix(reinterpret_cast<short *>(buffer[curBuffer]), BUFFER_SIZE_IN_SAMPLES);
|
||||||
|
@ -101,17 +100,14 @@ bool OpenSLESStream::Start()
|
||||||
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
|
result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
|
||||||
assert(SL_RESULT_SUCCESS == result);
|
assert(SL_RESULT_SUCCESS == result);
|
||||||
|
|
||||||
// Render and enqueue a first buffer. (or should we just play the buffer empty?)
|
// Render and enqueue a first buffer.
|
||||||
curBuffer = 0;
|
|
||||||
|
|
||||||
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeof(buffer[curBuffer]));
|
|
||||||
if (SL_RESULT_SUCCESS != result)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
curBuffer ^= 1;
|
curBuffer ^= 1;
|
||||||
g_mixer = m_mixer;
|
g_mixer = m_mixer;
|
||||||
|
|
||||||
|
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[0], sizeof(buffer[0]));
|
||||||
|
if (SL_RESULT_SUCCESS != result)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue