Reputation: 21
I've known only 32 objects which we can create in OpenSL SE Android, but when I create PCM AudioPlayer with following code, I got error when the 11st AudioPlayer has been created. The AudioPlayer can be used normally, the sound can be played normally. but why I can't create more at once time.
Anyone met the same issue, please help me. Thanks.
My source code is :
SLresult result;
// Set-up sound audio source.
SLDataLocator_AndroidSimpleBufferQueue lDataLocatorIn;
lDataLocatorIn.locatorType =
SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
// At most one buffer in the queue.
lDataLocatorIn.numBuffers = 1;
SLDataFormat_PCM lDataFormat;
lDataFormat.formatType = SL_DATAFORMAT_PCM;
lDataFormat.numChannels = 2; //
lDataFormat.samplesPerSec = SL_SAMPLINGRATE_44_1;
lDataFormat.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16;
lDataFormat.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16;
lDataFormat.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
lDataFormat.endianness = SL_BYTEORDER_LITTLEENDIAN;
SLDataSource lDataSource;
lDataSource.pLocator = &lDataLocatorIn;
lDataSource.pFormat = &lDataFormat;
SLDataLocator_OutputMix lDataLocatorOut;
lDataLocatorOut.locatorType = SL_DATALOCATOR_OUTPUTMIX;
lDataLocatorOut.outputMix = s_pOutputMixObject;
SLDataSink lDataSink;
lDataSink.pLocator = &lDataLocatorOut;
lDataSink.pFormat = NULL;
SLAndroidConfigurationItf playerConfig;
SLint32 streamType = SL_ANDROID_STREAM_VOICE;
// Creates the sounds player and retrieves its interfaces.
const SLuint32 lSoundPlayerIIDCount = 3;
const SLInterfaceID lSoundPlayerIIDs[] =
{ getInterfaceID("SL_IID_PLAY"), getInterfaceID("SL_IID_BUFFERQUEUE") , getInterfaceID("SL_IID_VOLUME")};
const SLboolean lSoundPlayerReqs[] =
{ SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
//create audioplayer for enqueue
result = (*s_pEngineEngine)->CreateAudioPlayer(s_pEngineEngine, &m_PlayerObj[channelIndex],
&lDataSource, &lDataSink, lSoundPlayerIIDCount,
lSoundPlayerIIDs, lSoundPlayerReqs);
assert(SL_RESULT_SUCCESS == result);
result = (*m_PlayerObj[channelIndex])->Realize(m_PlayerObj[channelIndex], SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
result = (*m_PlayerObj[channelIndex])->GetInterface(m_PlayerObj[channelIndex],
getInterfaceID("SL_IID_PLAY"), &m_Player[channelIndex]);
assert(SL_RESULT_SUCCESS == result);
result = (*m_PlayerObj[channelIndex])->GetInterface(m_PlayerObj[channelIndex],
getInterfaceID("SL_IID_BUFFERQUEUE"), &m_PlayerQueue[channelIndex]);
assert(SL_RESULT_SUCCESS == result);
// get the volume interface
result = (*m_PlayerObj[channelIndex])->GetInterface(m_PlayerObj[channelIndex],
getInterfaceID("SL_IID_VOLUME"), &m_PlayerVolume[channelIndex]);
assert(SL_RESULT_SUCCESS == result);
// Starts the sound player. Nothing can be heard while the
// sound queue remains empty.
result = (*m_Player[channelIndex])->SetPlayState(m_Player[channelIndex], SL_PLAYSTATE_PLAYING);
assert(SL_RESULT_SUCCESS == result);
the error log is :
08-20 21:05:56.960: A/libc(2015): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
Upvotes: 2
Views: 462
Reputation: 486
This isn't a particularly useful answer, however much like OpenGL functionality, the technical limitations of OpenSL will be dependent on the specific hardware the user has. You should revisit your use case and determine ways to reduce the number of channels you need.
Upvotes: 1