0

我正在开发一个Android纯粹C/C++的应用程序,该应用程序需要连续录制声音并同步处理数据,所以我想知道当我在openSL中使用缓冲区队列来录制声音时,我是否可以释放那些被填充的并在缓冲区队列中加入新的空队列?

我已经考虑了在所有缓冲区都填满时清除整个缓冲区队列并通过使用回调重新排队新缓冲区的解决方案,但我担心这个过程可能需要一些时间,并且我会在期间丢失数据时间。

4

1 回答 1

0

I'm unsure what your question exactly is. The buffer queue should be seen as a circular/ring queue, i.e.: you write the contents of a new buffer into the next queued (thus "free") buffer, when the current buffer finishes playing, the queued buffer becomes the current one, and the previously current buffer the new enqueued buffer, basically swapping their status. You needn't worry about this when recording and processing sound, but focus on a single, temporary buffer that you write into and write these contents into the enqueued buffer. Then the ring buffer for output can continue doing it's thing and on the next callback (i.e. when the buffers in the queue swap), you clear the content of the temporary buffer and fill it with all the magic you'd like it to hold. What it basically comes down to is that all your recording and rendering will take place after each callback and you have queue both for output and for input, which will overcome the possibility that data would be lost.

于 2014-02-27T14:10:51.923 回答