LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2007, 08:10 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Java Sound (alsa): Can't get a line (sound output)


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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to record the sound output (wave out) instead of input (mic/line-in) Thirteenth Zodiac Ubuntu 3 08-13-2007 03:13 PM
CD PLAYER SOUND CARD LINE-IN, then output sound to speaker out of compuer scrollups Linux - Hardware 2 06-07-2006 10:29 PM
sound from line-in or mic does not output to speaker sohmc Linux - Hardware 1 06-16-2005 08:28 AM
ALSA sound: One output at a time :( Erik Plaggenmar Linux - Software 4 10-09-2004 04:12 AM
no sound output (any more) with alsa on kernel 2.6 qanopus Linux - Software 1 12-17-2003 05:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration