'javax.sound.sampled.LineUnavailableException: null' ERROR trying to play audio. (Only on Ubuntu)

Hello! I have a problem thats been stumping me for a while. I’m quite new at developing Java and I may be in over my head with this one. Please forgive me if I haven’t posted in the correct format of something.

I am running Ubuntu 12.04 with ‘lightweight x11 desktop environment’ off of a BeagleBone Black. The Java code below is supposed to play a .wav file (Ive also tried switching to .mp3 with no luck) when a notification occurs. This all works fine on OSX but Errors out on the BeagleBone.

This is my troubleshooting so far:
I have successfully gotten the BeagleBone to make white noise through the terminal command

speaker-test -D default:CARD=Headset

I could NOT play anything using the following terminal command:

mplayer -ao alsa:device=default=Headset XXX.mp3

Also, I could not play anything using the built in audio player including the supplied .mp3. This may be irrelevant but I have also successfully commented out relevant java lines to avoid making any sound just so the program can run.

Heres the code:

package com.XXXXXX.ibis.notification;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import javax.sound.sampled.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AudioNotification implements INotification {

    /**

Oh also, I’m using a generic USB sound card FYI

ugh sorry. its also a beaglebone. not beaglebone black

In your methods that are catching exceptions, they’re continuing after you catch the exception
which is not what you want in general. When you catch an exception the program isn’t terminated
unless you throw one in the catch clause. Catching an exception means that you’re going to do
some sort of recovery in general, unless you throw another one in the catch clause. You could
also close file descriptors in the catch clause and then rethrow the exception that you caught.

Unless you’re going to do something when you catch the exception you should just let the
exceptions terminate the program, meaning that you’ll need to add the appropriate throws clauses.
That should also give you a stack trace which may be helpful. And it will include the name of
the exception, and possibly the reason.

I did a google search on javax.sound.sampled.LineUnavailableException and there were some
queries about that exception on StackOverflow. Try doing a google search and see what you find.

Have you been able to solve this problem? I am in the same situation. Thank you. This is what I am seeing:

Exception in thread “main” java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian is supported.# at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:476)# at javax.sound.sampled.AudioSystem.getClip(AudioSystem.java:520)# at org.mdpnp.helloice.Audio.play(Audio.java:46)# at org.mdpnp.helloice.HelloICE_Numeric.main(HelloICE_Numeric.java:208)

I am not sure if it has to do with Clip, AudioSystem, Mixer… Do we need to setup anything special due to JAVA being run on BBB? Do we need to modify */java/ejre1.7.0_45/lib/sound.properties file? If I do ‘arecord -l’ at command line I see my USB audio dongle:

Exception in thread “main” java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian is supported.# at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:476)# at javax.sound.sampled.AudioSystem.getClip(AudioSystem.java:520)# at org.mdpnp.helloice.Audio.play(Audio.java:46)# at org.mdpnp.helloice.HelloICE_Numeric.main(HelloICE_Numeric.java:208)

Thank you.