Solved

Need a FIFO in Java

Posted on 2004-08-03
8
1,469 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 96
ArrayIndexOutOfBoundException 9 80
Java Jpanels and Jframe 8 32
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 31
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

808 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