1
OpenSL SE 안드로이드에서 만들 수있는 객체는 입니다 만, 다음 코드로 PCM AudioPlayer를 만들면 11 번째 AudioPlayer에있을 때 오류가 발생합니다. 생성되었습니다. AudioPlayer를 정상적으로 사용할 수 있으며 사운드를 정상적으로 재생할 수 있습니다. 하지만 왜 나는 한 번에 더 많은 것을 만들 수 없습니다.안드로이드 용 OpenSL SE에서 얼마나 많은 PCM AudioPlayer를 만들 수 있습니까?
누구나 같은 문제가 발생했습니다. 제발 도와주세요. 감사.
내 소스 코드는 다음과 같습니다
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);
오류 로그는 다음과 같습니다
08-20 21:05:56.960: A/libc(2015): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)