Solved

Need a FIFO in Java

Posted on 2004-08-03
8
1,468 Views
Last Modified: 2008-02-01
Hi!

I've a audio stream whichI get via udp....

When the stream arrives as packet in 400 bytes, I need a FIFO where I can put more into it in the same time as I can playback it... Anybody got  a solution for that???
0
Comment
Question by:mamruoc
8 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11703635
Use two threads. One to play the audio and the other to store it in an ArrayList or another collection object.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 11703645
use one of the list implementation... putting more on the same or playback, you have to implement on your own.
There is no built in support of that in Java as I know
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 11703827
List fifo = Collections.synchronizedList(new ArrayList());


...


public void play() {
      if (fifo.isEmpty() == false) {
            byte[] bytes = (byte[])fifo.remove(0);
            playAudio(bytes);
      }
}      

public void queueForPlayback(byte[] bytes) {
      fifo.add(bytes);
}
0
 

Author Comment

by:mamruoc
ID: 11703925
Thanks again...

Maybe you should be the person how's doing this Java application.. :D
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 11704119
8-)
0
 

Author Comment

by:mamruoc
ID: 11725897
Hi!!

Hope you're still there...

Can your FIFO store binary data?

Seems like it don't play back that well... But if I send a file with content:

\x0A, it seems to store and playback well....

regards
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11734575
>>Can your FIFO store binary data?

Yes, as you can see, i assumed using a byte[]. Playback is another thing of course ...
0
 

Author Comment

by:mamruoc
ID: 11734622
Well,,

I just dropped using ArrayList and used Vector, seems like Vetor is more efficient....

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PDFBox - convert image to PDF, PDF resolution 3 117
Unable to start eclipse ? 17 132
Java DateChooser? 3 29
couple of eclipse 5 21
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now