Android NDK,OpenSL ES-知道何时填充缓冲区

如果我将要记录的缓冲区放入队列中,是否有办法知道该缓冲区的实际填充时间,所以我可以使用它?

同样,是否有办法知道何时播放了缓冲区?

对于上下文:
我正在修改NDK示例“本地音频”.
它使用SLAndroidSimpleBufferQueueItf进行播放,并使用注释(为了进行流录制)进行注释(我想这样做).
现在我想知道的是,从我记得在某处阅读的内容来看,不能保证在下一次调用录音回调时(或在播放回调中播放)已经填充了一个缓冲区-如何知道何时缓冲区已被使用?
当然必须有某种方法,因为否则所有这些都将毫无用处? ^^

解决方法:

为了进行记录,如果向IBufferQueue_RegisterCallback注册slBufferQueueCallback,则当缓冲区已满时,您应该获得回调.

另请参阅android-ndk列表上的this discussion

If I understand well, the recorder will call back each time a buffer in the queue is filled in, and these buffers are filled in in the order that they are enqueued. But the callback does not seem to expose a pointer to the corresponding filled buffer. So what would be the way to retreive this? A sample code in the OpenSL ES specs shows an example for playback with a struct passed in as context of the callback to keep track of these, is that the way to do?

Right. This is a known deficiency in the OpenSL ES 1.0.1 spec. OpenSL ES 1.1 adds an explicit parameter to identify the buffer, but Android is currently based on the 1.0.1 spec. A workaround is to maintain an index yourself to indicate which buffer is being completed.

上一篇:鸿蒙内核源码分析(物理内存篇) | 伙伴算法像极了在卖标准猪肉块 | 百篇博客分析HarmonyOS源码 | v17.03


下一篇:鸿蒙内核源码分析(用栈方式篇) | 栈是构建底层运行的基础 | 百篇博客分析HarmonyOS源码 | v20.04