开发者

Using RandomFileAccess to temporarly cache audio data

I'm currently using a simple byte array buffer to cache live audio data and than playback this data. So it's constant reads and wr开发者_如何学编程ites on this buffer. My problem is that I sometimes need this buffer to be atleast 1MB and I know that allocating that much memory is most likely not a good idea. So therefore I'm looking into caching data temporarily under the cache folder.

Are there any pitfalls when using RandomFileAccess to continuously seek->read and seek->write?

Are there perhaps better methods to cache temporarily data?

My main concerns are to maximize performance and battery life.


What you need is a MappedByteBuffer (in Java), or mmap() (in C).

This is nicely optimized on Linux, and actually used all over the place in the Android OS.

And you can almost forget about memory limits when using such mapped files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜