views:

244

answers:

1

How can we program a circular buffer for Blackberry?

+1  A: 

Are you looking for something like these, from the OstermillerUtils library? I don't think it's written for J2ME but if it doesn't compile it would at least give you some code as a starting point.

Marc Novakowski
I needed it to stream audio, video files. Circular or piped stream are necessary as space is limited on the device or the card.I can't afford to store the whole file.Nice link.Any more ideas how to??
Bohemian
If you want to do true streaming without storing or buffering data in memory, look into using RTSP which most BlackBerry devices support.
Marc Novakowski
Doesn't server need to support rtsp? Its just an audio/video file won the server which I am accessing.
Bohemian
Yes RTSP needs server-support as well. If you're just doing it over HTTP then it could be tricky as I've seen some devices (typically CDMA) want to seek to the start of the audio file for various reasons, so I'm not sure how well that will work for a circular buffer type implementation. Definitely worth experimenting - but be sure to test it on real devices and not just the simulator because real devices have many more quirks than simulators.
Marc Novakowski
By the way what do you suggest is a good way to buffer if we are making an http connection
Bohemian
In-memory is the best, but if you're constrained for space you could buffer on the SD card as well - but not all devices have an SD card in them.
Marc Novakowski
Presently I am buffering it to sdcard. It works fine but it has a limit as it cant save really big files as well. Thats y I was thinkin about this circular buffer so that the file keeps on playing and the used buffer data is getting replaced simulatneously. That way it will buffer anything no matter what
Bohemian