Audio Streaming on the BlackBerry

For the best audio playback on the BlackBerry, you should create a buffered input stream.

This buffered input stream will consist of X number of internal buffers, and each buffer should be a second of audio (For example, if the audio has a bitrate of 5120 bytes/second, the best performance is achieved when each buffer is also 5120 bytes).

A background thread will be started to continually read data from the server and store it in the buffers. The thread will simply sleep when it reaches the max number of buffers to be stored, and then is woken when more buffers should be read.

The buffered input stream should implement the read(byte[],int,int) method for optimal speed. This will use System.arraycopy to copy the audio data from the stream's buffers to the audio player. If no buffers are available, or more buffers are required to read the requested number of bytes, the stream will wait until enough streams are available.

This stream should also wait until a few buffers are full before starting initial playback. The main goal is to allow slower phones to stream smoothly even if their connection speed temporarily goes below the audio's bitrate - As long as their overall average speed is enough to stream, they should have uninterrupted playback.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© 2011 Metova, Inc.