我可以在OpenSL SE for Android中创建多少个PCM AudioPlayer

我可以在OpenSL SE for Android中创建多少个PCM AudioPlayer,android,audio,android-ndk,opensl,Android,Audio,Android Ndk,Opensl,我只知道我们可以在OpenSL SE Android中创建32个对象, 但当我用以下代码创建PCM AudioPlayer时,在创建第11个AudioPlayer时出现了错误。 音频播放器可以正常使用,声音可以正常播放。 但为什么我不能一次创造更多 任何人遇到同样的问题,请帮助我。谢谢 我的源代码是: SLresult result; // Set-up sound audio source. SLDataLocator_AndroidSimpleBufferQueue lDataLocato

我只知道我们可以在OpenSL SE Android中创建32个对象, 但当我用以下代码创建PCM AudioPlayer时,在创建第11个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)

这并不是一个特别有用的答案,但与OpenGL功能非常相似,OpenSL的技术限制将取决于用户拥有的特定硬件。您应该重新审视您的用例,并确定减少所需通道数量的方法