Posts: 25
Joined: Thu Aug 03, 2017 9:37 am

ALSA - AudioSystem.isLineSupported FAILS with USB MIC

Wed Oct 11, 2017 3:28 pm

i'm using an USB MIC on a Raspberry and i'm developing with the JAVA SOUND API
but the Line is Not Supported, why?
I've executed this code on a normal PC with Linux and it works (the Line is supported and the Mic works)
What is missing? how can is get Line Supported?

the cose is this:

Code: Select all

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Port;
import javax.sound.sampled.TargetDataLine;

public class TestAudio {

	public static void main(String[] args) throws LineUnavailableException {
		Mixer.Info minfo[] = AudioSystem.getMixerInfo();
		for (Mixer.Info minfo1 : minfo) {

		if (AudioSystem.isLineSupported(Port.Info.MICROPHONE)) {

			System.out.println("++ LINE IS SUPPORTED ++");
		} else {
			System.out.println("Line is NOT supported");



The output is this:

Code: Select all

ALSA [default], version 4.9.54-v7+
ALSA [plughw:0,0], version 4.9.54-v7+
ALSA [plughw:0,1], version 4.9.54-v7+
Device [plughw:1,0], version 4.9.54-v7+
Port ALSA [hw:0], version 4.9.54-v7+
Port Device [hw:1], version 4.9.54-v7+
Line is NOT supported

User avatar
Posts: 3360
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: ALSA - AudioSystem.isLineSupported FAILS with USB MIC

Fri Oct 13, 2017 5:49 pm

Sorry I can't assist, I have never tried developing in Java on any platform. The only things I've done on RPi like this is recording audio from a USB webcam with 'arecord' and also separately with 'ffmpeg' as described here: ... 0#p1006200

If you can get 'arecord' to work from the command line, that would demonstrate that the hardware and the Linux audio driver is working, and it is a higher-level issue with whatever tools you are using.

Posts: 351
Joined: Thu Oct 23, 2014 12:14 am

Re: ALSA - AudioSystem.isLineSupported FAILS with USB MIC

Fri Oct 13, 2017 7:19 pm

I'm not sure why that doesn't work but I've never been able to get a line from a Port that way (on Windows or Linux). If you want the microphone just get a TargetDataLine with the appropriate AudioFormat and it will be the microphone.

Please see my Intercom program at for some code examples.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 9 guests