Android上的OpenSLES中SL_DATALOCATOR_ADDRESS的用途是什么?

时间:2018-09-02 23:25:12

标签: android

有一个答案告诉a WAV cannot be played with SL_DATALOCATOR_ADDRESS

除此之外,还有另一个限制。我尝试使用以下代码在Android内存中播放WAV:

SLDataLocator_Address loc_addr = {SL_DATALOCATOR_ADDRESS,
  const_cast<uint8_t *>(GetBuffer()), static_cast<SLuint32>(GetSize())};

SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, 2, SL_SAMPLINGRATE_44_1,
    SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,
    SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT, SL_BYTEORDER_LITTLEENDIAN};

SLDataSource audioSrc = {&loc_addr, &format_pcm};

// configure audio sink
SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, oslContext.GetOutputMixObject()};
SLDataSink audioSnk = {&loc_outmix, nullptr};

//create audio player: fast audio does not support when SL_IID_EFFECTSEND is required, skip it for fast audio case

const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_MUTESOLO, SL_IID_VOLUME};
const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};

auto engine = oslContext.GetEngine();

CheckOsl((*engine)->CreateAudioPlayer(engine, &playerObj, &audioSrc, &audioSnk, 3, ids, req));

但是CreateAudioPlayer失败,错误为“ SL_DATALOCATOR_OUTPUTMIX接收器不支持源数据定位符0x2。”,其中0x2是SL_DATALOCATOR_ADDRESS。

SL_DATALOCATOR_ADDRESS的正确用法是什么,它可以播放什么样的声音?

0 个答案:

没有答案