LineUnavailableException

Help me, please! If I run this code:

import java.util.Random;

import javax.sound.sampled.AudioFormat;

import javax.sound.sampled.AudioInputStream;

import javax.sound.sampled.AudioSystem;

import javax.sound.sampled.DataLine;

import javax.sound.sampled.LineUnavailableException;

import javax.sound.sampled.SourceDataLine;

publicclass test{

publicstaticvoid main(String[] args){

try{

AudioFormat format =new AudioFormat(44100, 16, 2, true,false);

SourceDataLineline =null;

DataLine.Infoinfo =new DataLine.Info(SourceDataLine.class, format);

try

{

line = (SourceDataLine) AudioSystem.getLine(info);

}

catch (LineUnavailableException e)

{

e.printStackTrace();

System.exit(1);

}

line.open(format);

line.start();

int velikost = line.getBufferSize();

byte[] data =newbyte[velikost];

Random nahodne =new Random();

long start = System.currentTimeMillis();

for (int i = 0; i < 10; i++){

nahodne.nextBytes(data);

line.write(data, 0, velikost);

}

line.drain();

line.close();

}catch (LineUnavailableException e){

System.setErr(System.out);

e.printStackTrace();

}

}

}

I got this error mesage:

javax.sound.sampled.LineUnavailableException: line with format PCM_UNSIGNED 44100.0 Hz, 8 bit, mono, 1 bytes/frame, not supported.

at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(Unknown Source)

at com.sun.media.sound.AbstractDataLine.open(Unknown Source)

at com.sun.media.sound.AbstractDataLine.open(Unknown Source)

at test.main(test.java:24)

What I should to do?

[3052 byte] By [waflika] at [2007-11-27 9:02:43]
# 1
Have you tried to open your line as signed? Your system may just not offer unsigned line.
finn_hippiea at 2007-7-12 21:33:40 > top of Java-index,Security,Cryptography...