I create the URI player use the config as follows. My APP frequently "create -> play -> destroy" the URI player with WAV files, then sometimes it occurs a dead lock when destroy the player.
are there any notice I should pay attention to when I destory the player? or are there something wrong in the config as follows?
// configure audio source
// (requires the INTERNET permission depending on the uri parameter)
SLDataLocator_URI loc_uri = {SL_DATALOCATOR_URI, (SLchar *)uri};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
SLDataSource audioSrc = {&loc_uri, &format_mime};
// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject};
SLDataSink audioSnk = {&loc_outmix, NULL};
// create audio player
const SLInterfaceID ids[4] = {SL_IID_ANDROIDCONFIGURATION, SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME};
const SLboolean req[4] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
result = (*engineEngine)->CreateAudioPlayer(engineEngine, uriPlayerObjectP, &audioSrc,
&audioSnk, 4, ids, req);
// note that an invalid URI is not detected here, but during prepare/prefetch on Android,
// or possibly during Realize on other platforms
assert(SL_RESULT_SUCCESS == result);
(void)result;
// CreateAudioPlayer and specify SL_IID_ANDROIDCONFIGURATION
// in the required interface ID array. Do not realize player yet.
SLAndroidConfigurationItf uriPlayerConfig;
result = (**uriPlayerObjectP)->GetInterface(*uriPlayerObjectP, SL_IID_ANDROIDCONFIGURATION, &uriPlayerConfig);
assert(SL_RESULT_SUCCESS == result);
result = (*uriPlayerConfig)->SetConfiguration(uriPlayerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
assert(SL_RESULT_SUCCESS == result);
// realize the player
result = (**uriPlayerObjectP)->Realize(*uriPlayerObjectP, SL_BOOLEAN_FALSE);
// this will always succeed on Android, but we check result for portability to other platforms
if (SL_RESULT_SUCCESS != result) {
(**uriPlayerObjectP)->Destroy(*uriPlayerObjectP);
*uriPlayerObjectP = NULL;
return -1;
}
// get the play interface
result = (**uriPlayerObjectP)->GetInterface(*uriPlayerObjectP, SL_IID_PLAY, uriPlayerPlayP);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// register callback on the buffer queue
result = (**uriPlayerPlayP)->RegisterCallback(*uriPlayerPlayP, _uriPlayerCallback, (void *)uriPlayerP);
result = (**uriPlayerPlayP)->SetCallbackEventsMask(*uriPlayerPlayP, SL_PLAYEVENT_HEADATEND);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the seek interface
result = (**uriPlayerObjectP)->GetInterface(*uriPlayerObjectP, SL_IID_SEEK, uriPlayerSeekP);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the mute/solo interface
result = (**uriPlayerObjectP)->GetInterface(*uriPlayerObjectP, SL_IID_MUTESOLO, uriPlayerMuteSoloP);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the volume interface
result = (**uriPlayerObjectP)->GetInterface(*uriPlayerObjectP, SL_IID_VOLUME, uriPlayerVolumeP);
assert(SL_RESULT_SUCCESS == result);
(void)result;