?
Solved

Need a FIFO in Java

Posted on 2004-08-03
8
Medium Priority
?
1,474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mamruoc
ID: 11703925
Thanks again...

Maybe you should be the person how's doing this Java application.. :D
0
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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