03-05-2009 11:40 AM
I have a thread that gets a byte from a shared synchronized objet, and then pass it to a new ByteArrayInputStream that I create. The synchronized object has a ByteArrayOutputStream where buffer data recorded by another thread.
byte aux = theData.getDatos(); // getDatos return out.toByteArray()
byte copy = new byte[aux.length];
for(int i=0 ; i< aux.length - 1 ; i++)
copy[i] = aux[i];
theInput = new ByteArrayInputStream(copy);
If I get the copy.length , I can see that it's correct.
After this I create the player:
if ( theInput.available() > 0 )
player = Manager.createPlayer(theInput, "audio/amr");
System.out.println("##### Before REALIZE "+ theInput.available()+" BYTES");
System.out.println("##### Before PREFECTCH "+ theInput.available()+" BYTES");
System.out.println("##### Before START "+ theInput.available()+" BYTES");
System.out.println("##### PLAYING ....."+ theInput.available());
// sleep time enough for play all data ( the data are around 15 seconds)
I think that all this above is correct, but the player just plays three seconds and stop! the output of debug shows:
##### Before REALIZE 15320 BYTES
##### Before PREFETCH 0 BYTES
##### Before START 0 BYTES
##### PLAYING .....
AR: add source 10
AR: setAudioMode 32
MN: play0(1000000) is audio, NO check for active pause
MN: MEDIA_STOPPED received
MN: handle=1000000 staticsHandle=7fffffff
MN: unload0(1000000)=2 pauseHandle=7fffffff
AR: remove source 10
AR: setAudioMode 32
Streaming done reason=1 prev-state=300
I don´t understand why before perform the realize method,the buffer turn to 0, I try even remove the realize and prefetch calls and although output shows ##### Before START 15320 BYTES , it still playing three seconds!
Anyone understand what is happens??
Thanks and best regards!!
03-06-2009 02:47 AM
Hi everybody !
I discover this:
The recorder data thread, record through a player which start record and sleep 3000 ms (3 seconds) and then commit and write data in the share object, all this while player isn`t closed. I can see that the data is being accumulated, but when the above player thread try reproduce all accumulated data in the buffer, it only reproduce the fist recorded (the fist 3 seconds) !!
This is how I record:
while (thePlayer.getState() != Player.CLOSED)
theRcontrol = (RecordControl) thePlayer.getControl("RecordControl");
theOutput = new ByteArrayOutputStream();
size = theOutput.size();
byte auxArray = new byte[theOutput.toByteArray().length];
for(int i=0 ; i< auxArray.length - 1 ; i++)
auxArray [i] = theOutput.toByteArray()[i];
System.out.println("##### RECORDED " +size+ " Bytes");
// Write in the shared and synchronized object
theData is the shared and synchronized object and has a ByteArrayOutputStream member, theData.setDatos( auxArray )
just write the array in this ByteArrayOutputStream which belongs theData:
I can't understand why the player plays only 3 seconds if the array has bytes for plays more than 3 seconds.
I hope that someone can help me about this, It's driving me crazy, and need this works for my job.
Thanks everybody, and regards.
03-09-2009 04:23 AM
I realize that every time I take a record in my while (thePlayer.getState() != Player.CLOSED), theOutput.ToByteArray() always contains the following values at the fist positions of the byte array: 35,33,65,77,82,10,60
So every record commited in the ByteArrayOutputStream starts with this values.
Could be this the reason why the player only plays the frist record of all ??
03-13-2009 04:17 AM
I've been reading the RFC 4867 and I discover that the ascii values 35 33 65 77 82 10 mean #!AMR. It is a header, so when I take a record and I get the byte  from the ByteArrayOutputStream for write it in the shared ByteArrayInpuntStream, I do it writing the byte without this header. But I've the same problem, the player only plays the first record of all.
Are there any way to record several times in the same ByteArrayOutputStream without use commit ??
Commit ends the recording, so if I want a new recording, this recording will have a new header...and I don't want it.
Could someone enlighten me about this? I really worried with this. I'm beginning to think that people is right saying that girls aren't good developers
03-18-2009 12:58 PM
When you call commit it completes the recording. The next recording you make will be completely new. Each recording creates a single, stand alone file.
You can use the RecordControl.stopRecord and RecordControl.startRecord methods to start and stop recording. Once you have finished recording you can call commit and have the entire recording available as a single file.
03-23-2009 04:17 AM
I realized it, but the problem is that I need get the recording data anytime from another thread, so I can't get that data without call commit.
As far I can see, there is no way to get the data without commit.
Thanks all !
08-04-2010 03:33 AM
still interested ?
I guess not. but someone else might be.
you can call toByteArray(), and then reset() on the OutputStream