OpenSL|ES: Use ANDROIDSIMPLEBUFFERQUEUE instead of BUFFERQUEUE.

This commit is contained in:
David Reid
2016-10-25 10:02:08 +10:00
parent 1b20f53291
commit b7b1cd6b72
+10 -2
View File
@@ -3029,7 +3029,7 @@ static mal_result mal_device_init__slse(mal_device* pDevice, mal_device_type typ
pDevice->bufferSizeInFrames = pDevice->sles.periodSizeInFrames * periods; pDevice->bufferSizeInFrames = pDevice->sles.periodSizeInFrames * periods;
SLDataLocator_BufferQueue queue; SLDataLocator_BufferQueue queue;
queue.locatorType = SL_DATALOCATOR_BUFFERQUEUE; queue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
queue.numBuffers = periods; queue.numBuffers = periods;
SLDataFormat_PCM pcm; SLDataFormat_PCM pcm;
@@ -3075,7 +3075,7 @@ static mal_result mal_device_init__slse(mal_device* pDevice, mal_device_type typ
sink.pLocator = &outmixLocator; sink.pLocator = &outmixLocator;
sink.pFormat = NULL; sink.pFormat = NULL;
const SLInterfaceID itfIDs1[] = {SL_IID_BUFFERQUEUE}; const SLInterfaceID itfIDs1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};
const SLboolean itfIDsRequired1[] = {SL_BOOLEAN_TRUE}; const SLboolean itfIDsRequired1[] = {SL_BOOLEAN_TRUE};
if ((*g_malEngineSL)->CreateAudioPlayer(g_malEngineSL, (SLObjectItf*)&pDevice->sles.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1) != SL_RESULT_SUCCESS) { if ((*g_malEngineSL)->CreateAudioPlayer(g_malEngineSL, (SLObjectItf*)&pDevice->sles.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1) != SL_RESULT_SUCCESS) {
mal_device_uninit__slse(pDevice); mal_device_uninit__slse(pDevice);
@@ -3142,6 +3142,7 @@ static mal_result mal_device__start_backend__slse(mal_device* pDevice)
{ {
mal_assert(pDevice != NULL); mal_assert(pDevice != NULL);
if (pDevice->type == mal_device_type_playback) {
SLresult resultSL = MAL_SLES_PLAY(pDevice->sles.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->sles.pAudioPlayer, SL_PLAYSTATE_PLAYING); SLresult resultSL = MAL_SLES_PLAY(pDevice->sles.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->sles.pAudioPlayer, SL_PLAYSTATE_PLAYING);
if (resultSL != SL_RESULT_SUCCESS) { if (resultSL != SL_RESULT_SUCCESS) {
return MAL_FAILED_TO_START_BACKEND_DEVICE; return MAL_FAILED_TO_START_BACKEND_DEVICE;
@@ -3158,6 +3159,9 @@ static mal_result mal_device__start_backend__slse(mal_device* pDevice)
return MAL_FAILED_TO_START_BACKEND_DEVICE; return MAL_FAILED_TO_START_BACKEND_DEVICE;
} }
} }
} else {
// TODO: Implement me.
}
return MAL_SUCCESS; return MAL_SUCCESS;
} }
@@ -3166,10 +3170,14 @@ static mal_result mal_device__stop_backend__slse(mal_device* pDevice)
{ {
mal_assert(pDevice != NULL); mal_assert(pDevice != NULL);
if (pDevice->type == mal_device_type_playback) {
SLresult resultSL = MAL_SLES_PLAY(pDevice->sles.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->sles.pAudioPlayer, SL_PLAYSTATE_STOPPED); SLresult resultSL = MAL_SLES_PLAY(pDevice->sles.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->sles.pAudioPlayer, SL_PLAYSTATE_STOPPED);
if (resultSL != SL_RESULT_SUCCESS) { if (resultSL != SL_RESULT_SUCCESS) {
return MAL_FAILED_TO_STOP_BACKEND_DEVICE; return MAL_FAILED_TO_STOP_BACKEND_DEVICE;
} }
} else {
// TODO: Implement me.
}
// Make sure any queued buffers are cleared. // Make sure any queued buffers are cleared.
MAL_SLES_BUFFERQUEUE(pDevice->sles.pBufferQueue)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->sles.pBufferQueue); MAL_SLES_BUFFERQUEUE(pDevice->sles.pBufferQueue)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->sles.pBufferQueue);