09-01-2009 08:42 AM
hi,
My apllication is workink with diffrent aproach , so the dta is valid ans having AMR header as well, My problem is that i am not able to find the perfect way to write the data on NoCopyByteArrayOutputStream ,
09-01-2009 08:57 AM
09-01-2009 09:13 AM
hi,
Sorry i think u doesn't understatd my problem, i mean to say , i am passing the reference of NoCopyByteArrayOutputStream to diffrent thread, and that thread is writing the data on it , and how to block the stream here.
if (bytesToReturn < 1) {
// TODO: Need to block here on the stream until some bytes are available
return 0;
}
09-01-2009 09:54 AM
You could always use the standard Java synchronization primitives for that. You create a monitor that is referenced by both the reader and the writer. The writer, every time it wants to write something to the stream, acquires the monitor, writes to the stream, notifies all threads waiting on monitor and then releases the monitor. The reader, every time it wants to read something from the stream, acquires the monitor, goes into loop where it checks if there's anything to read. If there is something to read, it reads as much as it can/wants without blocking, releases the monitor and returns the read data. If there isn't anything to read, it waits for a notification on the monitor (this blocks the reader). Once a notification arrives, the reader goes into the next iteration of the above loop.
In the above design, the reader will read data without blocking when there's data available, and, if there's no data available, will block until some data is available. In your case the reader will be the thread the code that provides AMR frames to the system's audio player.
09-14-2009 05:06 AM
Hi i am geting this wahle debbugging the application .
SMP
treaming session aquired id=2056
MN: init0(0)=0
MN: load 0
Starting net_rim_bb_simphonebook
Started net_rim_bb_simphonebook(158)
JVM: bklt @7917: timer
JVM: bklt[1] @7917: idle 0
JVM: bklt @7917: setTimer 22
MN: getPlayableStreams0(0)=1
MN: getLength0(0)=-1
MN: getPlayableStreams0(0)=1
MN: isSeekable0(0)=0
AR: add source 11
AR: setAudioMode 32
MN: play0(0) is audio, NO check for active pause
MN: play0(0)=0
running
EF: 20 SIZE: -1
MN: unload0(0)=2 pauseHandle=7fffffff
AR: remove source 11
AR: setAudioMode 32
MN: MEDIA_STOPPED received
MN: handle=0 staticsHandle=7fffffff
Streaming done reason=1 prev-state=300
thanks
09-14-2009 06:35 AM
09-29-2009 07:59 AM
hi marek,
in the code u've posted how do tell the stream to only read X bytes and play it back ? And how do modify/add bytes to your baos ? i wanted to have a simple player that woul play a stream ( a stream that i want to update in real time)
tkz
09-30-2009 03:49 AM
10-05-2009 08:46 AM
Hi Marek_,
I am trying to do the same .. realtime streaming using datasource.
But here is the traces that reports failed to start player.
Source stream READ request : CuurentPosition0 len: 58000 offset: 0
Source stream READ request : CuurentPosition6156 len: 51844 offset: 6156
RTPSourceStream getContentLength
RTPSourceStream getSeekType
Source stream READ request : CuurentPosition6156 len: 51844 offset: 6156
RTPSourceStream getContentLength
SMP
treaming session aquired id=2313
MN: init0(0)=0
MN: load 0
After start play
PLAYERCallback :: Player eventsss : com.rim.loading : EventData null
Source stream READ request : CuurentPosition6156 len: 51844 offset: 6156
Source stream READ request : CuurentPosition12306 len: 45694 offset: 12306
MN: getPlayableStreams0(0)=1
MN: getLength0(0)=-1
MN: getPlayableStreams0(0)=1
MN: isSeekable0(0)=0
Source stream READ request : CuurentPosition12306 len: 45694 offset: 12306
PLAYERCallback :: Player eventsss : com.rim.mediaLoaded : EventData null
PLAYERCallback :: Player eventsss : com.rim.seekableUpdate : EventData false
AR: add source 9
AR: setAudioMode 32
PLAYERCallback :: Player eventsss : com.rim.playableStreams : EventData 1
MN: play0(0) is audio, NO check for active pause
MN: play0(0)=0
MN: MEDIA_STOPPED received
MN: handle=0 staticsHandle=7fffffff
PLAYERCallback :: Player eventsss : started : EventData 0
PLAYERCallback :: Player eventsss : bufferingStopped : EventData 0
PLAYERCallback :: Player eventsss : error : EventData 5
AUDIOMANAGER: IOException
MN: unload0(0)=2 pauseHandle=7fffffff
AR: remove source 9
AR: setAudioMode 32
PLAYERCallback :: Player eventsss : stopped : EventData 0
Streaming done reason=1 prev-state=300
When no data is available it will go into sleep mode by calling Thread.sleep() , so other thread can get a chance to write into bios.
Can you please tell me what goes wrong ???
10-05-2009 09:20 AM