How can I get a line on linux?
Here's the testing code I'm using:
Code:
// audio format
AudioFormat format = new AudioFormat(44100f, 16, 2, true, false);
System.out.println("Sound Format: " + format);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
SourceDataLine line = null;
Mixer.Info [] mixerInfo = AudioSystem.getMixerInfo();
// Let's look for a line that supports our DataLine.Info
Mixer mixer;
for (int i = 0; line == null && i < mixerInfo.length; i++) {
mixer = AudioSystem.getMixer(mixerInfo[i]);
System.out.println("Mixer: " + mixerInfo[i].getName() + ": " + mixerInfo[i].getDescription());
try {
line = (SourceDataLine) mixer.getLine(info);
if (!line.getLineInfo().matches(info)) {
System.out.println("The line doesn't match the format!");
line = null;
}
} catch (LineUnavailableException e) {
System.out.println("Line Unavailable!");
line = null;
} catch (IllegalArgumentException e) {
System.out.println("Illegal Argument!");
line = null;
}
System.out.println();
}
if (line == null) {
System.out.println("No line was found");
System.exit(1);
}
When I run it, here's the output:
Code:
Sound Format: PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
Mixer: ICH5 [plughw:0,0]: Direct Audio Device: Intel ICH5, Intel ICH, Intel ICH5
Illegal Argument!
Mixer: ICH5 [plughw:0,1]: Direct Audio Device: Intel ICH5, Intel ICH - MIC ADC, Intel ICH5 - MIC ADC
Illegal Argument!
Mixer: ICH5 [plughw:0,2]: Direct Audio Device: Intel ICH5, Intel ICH - MIC2 ADC, Intel ICH5 - MIC2 ADC
Illegal Argument!
Mixer: ICH5 [plughw:0,3]: Direct Audio Device: Intel ICH5, Intel ICH - ADC2, Intel ICH5 - ADC2
Illegal Argument!
Mixer: ICH5 [plughw:0,4]: Direct Audio Device: Intel ICH5, Intel ICH - IEC958, Intel ICH5 - IEC958
The line doesn't match the format!
Mixer: Java Sound Audio Engine: Software mixer and synthesizer
The line doesn't match the format!
Mixer: Port ICH5 [hw:0]: Intel ICH5, Realtek ALC202 rev 0
Illegal Argument!
Couldn't find a line
If I change it to big endian, I get the same output (except for the format, of course).
How can I solve this? Am I doing something wrong?