只是为了确认。当通过OpenSL eS为Android创建的音频播放器完成播放缓冲区时,缓冲区是由垃圾收集器自动释放的吗?或者我需要自我释放缓冲区吗?

如果是后者,我可以使用一些帮助。但似乎现在,在我被告知之前我不会发布任何代码,我需要自己做...

有帮助吗?

解决方案

The buffer queue doesn't actually allocate buffer memory itself (or need to free it), you pass in pointers to memory you have allocated via the 'enqueue' function. You will need to free the memory you allocated when you're finished playing buffers.

As OpenSL ES is a native library in C++, it knows nothing of garbage collection, any memory you allocate for the API must be freed by you, and objects you create must have 'destroy' called on them to clean up internal memory.

其他提示

As the previous poster said, you call Enqueue with a buffer you have created previously. I'd point out, however, that unless you're playing only one audio event once in your app, you should probably keep re-using your audio buffers to avoid GC altogether - the beauty of C!

Also check out the Android OpenSL ES doc concerning Destroying your interfaces once your done with them, that has to be done manually.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top