【发布时间】:2016-11-18 16:21:37
【问题描述】:
我正在为所有音频文件使用 SLDataLocator_AndroidSimpleBufferQueue。 效果很好,但是... 它不支持搜索和循环。
OpenSL 不能要求带有缓冲队列数据源的 SL_IID_SEEK
如何对文件使用循环?无法使用流式传输 - 低延迟。
【问题讨论】:
标签: android android-ndk opensl
我正在为所有音频文件使用 SLDataLocator_AndroidSimpleBufferQueue。 效果很好,但是... 它不支持搜索和循环。
OpenSL 不能要求带有缓冲队列数据源的 SL_IID_SEEK
如何对文件使用循环?无法使用流式传输 - 低延迟。
【问题讨论】:
标签: android android-ndk opensl
我用播放器回调函数上的缓冲队列入队函数解决了这个问题。
这样的示例代码...
struct PARAM { char* buffer; long size; };
void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue, void *context)
{
...
PARAM* param = (PARAM*)context;
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, param->buffer, nparam->size);
}
void createAudioPlayer... {
(*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, ...);
...
PARAM* param = new PARAM{buffer, size};
result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, param);
}
【讨论】:
事实证明,SLDataLocator_AndroidSimpleBufferQueue 无法做到这一点。
不得不使用SLDataLocator_AndroidFD...
【讨论】: