i'm trying creating engine and output Mix:
// create engine
this->res = slCreateEngine(&this->engineObject, 0, NULL, 0, NULL, NULL);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Create Engine.");
this->Free();
return;
}
this->res = (*this->engineObject)->Realize(this->engineObject, SL_BOOLEAN_FALSE);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Realize Engine.");
this->Free();
return;
}
this->res = (*this->engineObject)->GetInterface(this->engineObject, SL_IID_ENGINE, &this->engineEngine);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't GetInterface Engine.");
this->Free();
return;
}
// create output mix
this->res = (*this->engineEngine)->CreateOutputMix(this->engineEngine, &this->outputmixObject, 0, NULL, NULL);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Create Output Mix.");
this->Free();
return;
}
this->res = (*this->outputmixObject)->Realize(this->outputmixObject, SL_BOOLEAN_FALSE);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Realize Output Mix.");
this->Free();
return;
}
that is successful!
Start playing mp3 stream from IceCast (example "http://example.com/stream320"):
SLDataLocator_URI loc_uri = {SL_DATALOCATOR_URI, filename};
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, (SLchar*)NULL, SL_CONTAINERTYPE_UNSPECIFIED};
SLDataSource audioSrcuri = {&loc_uri, &format_mime};
SLDataLocator_OutputMix dataLocatorOut = {SL_DATALOCATOR_OUTPUTMIX,this->outputmixObject};
SLDataSink audioSnk = {&dataLocatorOut, NULL};
const SLInterfaceID pIDs[3] = {SL_IID_PLAY, SL_IID_SEEK, SL_IID_PREFETCHSTATUS};
const SLboolean pIDsRequired[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
this->res = (*this->engineEngine)->CreateAudioPlayer(this->engineEngine, &this->player, &audioSrcuri, &audioSnk, 3, pIDs, pIDsRequired);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Create Audio Player.");
return;
}
this->res = (*this->player)->Realize(this->player, SL_BOOLEAN_FALSE);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Realize Audio Player.");
return;
}
this->res = (*this->player)->GetInterface(this->player, SL_IID_PLAY, &this->playerInterface);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Get Interface \"SL_IID_PLAY\" from Audio Player.");
return;
}
this->res = (*this->player)->GetInterface(this->player, SL_IID_SEEK, &this->seekInterface);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Get Interface \"SL_IID_SEEK\" from Audio Player.");
return;
}
this->res = (*this->player)->GetInterface(this->player, SL_IID_PREFETCHSTATUS, &this->prefetchInterface);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Get Interface \"SL_IID_PREFETCHSTATUS\" from Audio Player.");
return;
}
this->res = (*this->playerInterface)->SetPlayState(this->playerInterface, SL_PLAYSTATE_PAUSED);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Set Play State \"SL_PLAYSTATE_PAUSED\".");
return;
}
this->LastPlayState = SL_PLAYSTATE_PAUSED;
/*SLuint32 prefetchStatus = SL_PREFETCHSTATUS_UNDERFLOW;
while (prefetchStatus != SL_PREFETCHSTATUS_SUFFICIENTDATA)
{
LOGI("Wait until there's data to play...");
usleep(1 * 1000);
(*this->prefetchInterface)->GetPrefetchStatus(this->prefetchInterface, &prefetchStatus);
}
LOGI("Data OK.");
/* Get duration */
SLmillisecond durationInMsec = SL_TIME_UNKNOWN;
this->res = (*this->playerInterface)->GetDuration(this->playerInterface, &durationInMsec);
if (SL_RESULT_SUCCESS != this->res)
{
LOGI("Can't Get Duration.");
return;
}
if (durationInMsec == SL_TIME_UNKNOWN) {
LOGI("durationInMsec = SL_TIME_UNKNOWN");
//durationInMsec = 5000;
}
(*this->seekInterface)->SetLoop(this->seekInterface,SL_BOOLEAN_FALSE,0,SL_TIME_UNKNOWN);
filename = "http://example.com/stream320";
LogCat began print a Error msg...:
E/libOpenSLES(16432): MEDIA_BUFFERING_UPDATE -491520000% < 0 E/libOpenSLES(16432): MEDIA_BUFFERING_UPDATE -655360000% < 0 E/libOpenSLES(16432): MEDIA_BUFFERING_UPDATE -819200000% < 0 ...
but stream is playing! Ok, so i'm trying stop playing:
this->res = (*this->playerInterface)->SetPlayState(this->playerInterface, SL_PLAYSTATE_STOPPED);
if (SL_RESULT_SUCCESS != this->res)
LOGI("Can't Set Play State \"SL_PLAYSTATE_STOPPED\".");
OK! Play really is stopped, but player continues downloading stream. ???
So i'm try destroy PlayerObj:
(*this->player)->Destroy(this->player);
LogCat printed Error msg:
A//system/bin/app_process(16690): stack corruption detected: aborted
and app process terminated. What is wrong?