Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
floydian
Posts: 16
Registered: ‎10-12-2009
My Device: Not Specified
Accepted Solution

RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

Hi,

 

I have been trying to solve one problem which occurs when streaming AMR audio for over a week.

Unfortunately, I could not find any reasonable explanation of this issue and that's why I ask you for help.

 

One Blackberry device records AMR audio and sends it to the other BB device as RTP packets. The other side receives the data and correctly plays it back for the first 30 seconds. Then either an exception is thrown on OS 6: "RT IOException: java.io.IOException: RimStreamingWriteBuffer failed" or an error from player listener “eventData = 5” on OS 5 and OS 7. All audio frames are built correctly and this problem only occurs when streaming between two Blackberry devices. AMR is played well on any other audio client.

 

Beside my implementation of the receiver and player (writing received packets into CircularByteBuffer and reading them with DataSource/SourceStream) I also checked out the Linphone's logic but the problem remains.

 

The most interesting fact is when I introduced a simple mechanism on the sender side responsible for sending RTP packets every 25 (or more) ms then the player on the other device plays the audio without any error! However, since sender holds data for too long (AMR frame is 20 ms long), a delay appears in playback which constantly arises. If AMR packets are sent as soon as recorder provides them or the timespan between sending them is too short (less than 25 ms), the issue occurs on the other BB device. 

 

A similiar logic in the receiver (waiting 20 ms or more before writing a received packet into player's buffer) does not help.

 

Could anybody help me?

Thanks,

Adam 

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
gsandhu
Posts: 41
Registered: ‎07-14-2008
My Device: Not Specified

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

Hi, are you able to simultaneously record and playback audio on the same device without any error?
Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

Did you try to sanitize each frame before you send it? How does your code handle the circular buffer if it is full?

Please use plain text.
Contributor
floydian
Posts: 16
Registered: ‎10-12-2009
My Device: Not Specified

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

What do you mean by sanitizing every frame? 

 

The circular buffer is relatively large and the error occurs long before written data reaches the end of the buffer. Anyway, if it is full new audio overwrites the old one from the start. 

 

Thanks,

adam 

Please use plain text.
Contributor
floydian
Posts: 16
Registered: ‎10-12-2009
My Device: Not Specified

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

@gsandhu - yes, I am but in this example I am using a simplex channel to simplify my problem investigation.

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR


floydian wrote:

What do you mean by sanitizing every frame? 

 

The circular buffer is relatively large and the error occurs long before written data reaches the end of the buffer. Anyway, if it is full new audio overwrites the old one from the start. 

 

Thanks,

adam 


Sanitizing the frame mean to make sure each frame is an AMR frame before sending it to the player.

Please use plain text.
Contributor
floydian
Posts: 16
Registered: ‎10-12-2009
My Device: Not Specified

Re: RimStreamingWriteBuffer failed or eventData = 5 when playing AMR

Thanks! This was a very helpful tip! 

 

My RTP sender class normally reads 32 bytes of AMR data from recoder's buffer. At one point though, it read 6 bytes less and as a result built in the next loop an AMR frame with an incorrect byte describing the "table of content". 

 

Now the player works fine on the other device.

Many thanks again!

Greetings! 

Please use plain text.