<Sound Dev> sound on Linux

View: New views
13 Messages — Rating Filter:   Alert me  

<Sound Dev> sound on Linux

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anybody tested java sound on linux? As I know, java uses ALSA on Linux to play audio.. so, i have a problem with it: when java plays sound, other applications can't play anything. When other applications plays sound, java can't. As i know, mplayer can play sound via ALSA and i can open many players and all of them will plays as expected...



Re: <Sound Dev> sound on Linux

by i30817 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I was just looking at this problem a while ago... opening the java
sound audio engine instead of the default one might be a solution.
Actually right now i'm using the method bellow, however, there are
still some errors on a test machine that exhibited errors before (but
no exception anymore) - the errors come in a Fedora (Pulse-Audio)
linux. Obviously if it can't open the mixer it will try to open the
java sound audio engine one - that should take take of one of the
errors java not playing, but still might cause the second - native
applications not playing.
Actually the guy that is running the tests for me in that machine
reports that audio is inaudible still, but no exception is raised if i
use this.

    /**
     * Lines can fail to open because they are already in use.
     * Java sound uses OSS and some linuxes are using pulseaudio.
     * OSS needs exclusive access to the line, and pulse audio
     * highjacks it. Try to open another line.
     * @param format
     * @return a open line
     * @throws IllegalStateException if it can't open a dataline for the
     * audioformat.
     */
    private SourceDataLine getSourceDataLine(AudioFormat format) {
        Exception audioException = null;
        try {
            DataLine.Info info = new
DataLine.Info(SourceDataLine.class, format);

            for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
                SourceDataLine dataline = null;
                try {
                    Mixer mixer = AudioSystem.getMixer(mi);
                    dataline = (SourceDataLine) mixer.getLine(info);
                    dataline.open(format);
                    dataline.start();
                    return dataline;
                } catch (Exception e) {
                    audioException = e;
                }
                if (dataline != null) {
                    try {
                        dataline.close();
                    } catch (Exception e) {
                    }
                }
            }
        } catch (Exception e) {
            throw new IllegalStateException("Error trying to aquire
dataline.", e);
        }
        if (audioException == null) {
            throw new IllegalStateException("Couldn't aquire a
dataline, this computer doesn't seem to have audio output?");
        } else {
            throw new IllegalStateException("Couldn't aquire a
dataline, probably because all are in use. Last exception:",
audioException);
        }
    }

Re: <Sound Dev> sound on Linux

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I already wrote the same code but it still does not work. It conflicts with flash player and with mplayer (in any mode).

2009/10/14 Paulo Levi <i30817@...>
I was just looking at this problem a while ago... opening the java
sound audio engine instead of the default one might be a solution.
Actually right now i'm using the method bellow, however, there are
still some errors on a test machine that exhibited errors before (but
no exception anymore) - the errors come in a Fedora (Pulse-Audio)
linux. Obviously if it can't open the mixer it will try to open the
java sound audio engine one - that should take take of one of the
errors java not playing, but still might cause the second - native
applications not playing.
Actually the guy that is running the tests for me in that machine
reports that audio is inaudible still, but no exception is raised if i
use this.

   /**
    * Lines can fail to open because they are already in use.
    * Java sound uses OSS and some linuxes are using pulseaudio.
    * OSS needs exclusive access to the line, and pulse audio
    * highjacks it. Try to open another line.
    * @param format
    * @return a open line
    * @throws IllegalStateException if it can't open a dataline for the
    * audioformat.
    */
   private SourceDataLine getSourceDataLine(AudioFormat format) {
       Exception audioException = null;
       try {
           DataLine.Info info = new
DataLine.Info(SourceDataLine.class, format);

           for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
               SourceDataLine dataline = null;
               try {
                   Mixer mixer = AudioSystem.getMixer(mi);
                   dataline = (SourceDataLine) mixer.getLine(info);
                   dataline.open(format);
                   dataline.start();
                   return dataline;
               } catch (Exception e) {
                   audioException = e;
               }
               if (dataline != null) {
                   try {
                       dataline.close();
                   } catch (Exception e) {
                   }
               }
           }
       } catch (Exception e) {
           throw new IllegalStateException("Error trying to aquire
dataline.", e);
       }
       if (audioException == null) {
           throw new IllegalStateException("Couldn't aquire a
dataline, this computer doesn't seem to have audio output?");
       } else {
           throw new IllegalStateException("Couldn't aquire a
dataline, probably because all are in use. Last exception:",
audioException);
       }
   }



--
-----------------------------------------------------------------
Всего наилучшего

                         <y6erGn0m.

Re: <Sound Dev> sound on Linux

by i30817 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try to make the default engine the java audio engine... I think i had
a test case to see if it worked around here... replace the string for
the wav file, and also, probably the "Java Sound Audio Engine" is not
the correct name string in the comparator ... you'll have to see. I
can't test this now since i don't have a linux here this fails handy.

[SoundPlayer.java]

import java.io.Closeable;
import java.io.File;
import java.io.IOException;

import java.util.Arrays;
import java.util.Comparator;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Mixer.Info;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import marytts.util.data.audio.MonoAudioInputStream;
import marytts.util.data.audio.StereoAudioInputStream;


public class SoundPlayer implements Runnable, Closeable {

    public static final int MONO = 0;
    public static final int STEREO = 3;
    public static final int LEFT_ONLY = 1;
    public static final int RIGHT_ONLY = 2;

    public enum Status {

        WAITING, PLAYING
    };
    private final LineListener lineListener;
    private final int outputMode;
    private volatile Status status = Status.WAITING;
    private volatile AudioInputStream ais;
    private volatile SourceDataLine line;
    private volatile boolean exitRequested;
    private volatile boolean isPaused;
    private volatile boolean isCancelled;

    public static void main(String ... args) throws Exception{
       
            SoundPlayer p = new SoundPlayer(new File("shoeshineshop.wav"));
            p.run();

    }

    /**
     * AudioPlayer which can be used if audio stream is to be set separately, using setAudio().
     *
     */
    public SoundPlayer() {
        this.outputMode = MONO;
        this.lineListener = null;
    }

    public SoundPlayer(File audioFile) throws IOException, UnsupportedAudioFileException {
        this.ais = AudioSystem.getAudioInputStream(audioFile);
        this.outputMode = MONO;
        this.lineListener = null;
        initAudioInputStream(ais.getFormat());
    }

    public SoundPlayer(AudioInputStream ais) {
        this.ais = ais;
        this.outputMode = MONO;
        this.lineListener = null;
        initAudioInputStream(ais.getFormat());
    }

    public SoundPlayer(File audioFile, LineListener lineListener)
            throws IOException, UnsupportedAudioFileException {
        this.ais = AudioSystem.getAudioInputStream(audioFile);
        this.lineListener = lineListener;
        this.outputMode = MONO;
        initAudioInputStream(ais.getFormat());
    }

    public SoundPlayer(AudioInputStream ais, LineListener lineListener) {
        this.ais = ais;
        this.lineListener = lineListener;
        this.outputMode = MONO;
        initAudioInputStream(ais.getFormat());
    }

    public SoundPlayer(File audioFile, SourceDataLine line, LineListener lineListener)
            throws IOException, UnsupportedAudioFileException {
        this.ais = AudioSystem.getAudioInputStream(audioFile);
        this.line = line;
        this.lineListener = lineListener;
        this.outputMode = MONO;
        initAudioInputStream(ais.getFormat());
    }

    public SoundPlayer(AudioInputStream ais, SourceDataLine line, LineListener lineListener) {
        this.ais = ais;
        this.line = line;
        this.lineListener = lineListener;
        this.outputMode = MONO;
        initAudioInputStream(ais.getFormat());
    }

    /**
     *
     * @param audioFile
     * @param line
     * @param lineListener
     * @param outputMode if MONO, force output to be mono; if STEREO, force output to be STEREO;
     * if LEFT_ONLY, play a mono signal over the left channel of a stereo output, or mute the
     * right channel of a stereo signal; if RIGHT_ONLY, do the same with the right output channel.
     * @throws IOException
     * @throws UnsupportedAudioFileException
     */
    public SoundPlayer(File audioFile, SourceDataLine line, LineListener lineListener, int outputMode)
            throws IOException, UnsupportedAudioFileException {
        this.ais = AudioSystem.getAudioInputStream(audioFile);
        this.line = line;
        this.lineListener = lineListener;
        this.outputMode = outputMode;
        initAudioInputStream(ais.getFormat());
    }

    /**
     *
     * @param ais
     * @param line
     * @param lineListener
     * @param outputMode if MONO, force output to be mono; if STEREO, force output to be STEREO;
     * if LEFT_ONLY, play a mono signal over the left channel of a stereo output, or mute the
     * right channel of a stereo signal; if RIGHT_ONLY, do the same with the right output channel.
     */
    public SoundPlayer(AudioInputStream ais, SourceDataLine line, LineListener lineListener, int outputMode) {
        this.ais = ais;
        this.line = line;
        this.lineListener = lineListener;
        this.outputMode = outputMode;
        initAudioInputStream(ais.getFormat());
    }

    private void initAudioInputStream(AudioFormat audioFormat) {
        if (audioFormat.getChannels() == 1) {
            if (outputMode != MONO) {
                ais = new StereoAudioInputStream(ais, outputMode);
                audioFormat = ais.getFormat();
            }
        } else {
            assert audioFormat.getChannels() == 2 : "Unexpected number of channels: " + audioFormat.getChannels();
            if (outputMode == MONO) {
                ais = new MonoAudioInputStream(ais);
            } else if (outputMode == LEFT_ONLY) {
                ais = new StereoAudioInputStream(ais, outputMode);
            } else if (outputMode == RIGHT_ONLY) {
                ais = new StereoAudioInputStream(ais, outputMode);
            } else {
                assert outputMode == STEREO : "Unexpected output mode: " + outputMode;
            }
        }
    }

    public void setAudio(AudioInputStream audio) {
        if (status == Status.PLAYING) {
            throw new IllegalStateException("Cannot set audio while playing");
        }
        initAudioInputStream(audio.getFormat());
        this.ais = audio;
    }

    /**
     * Queries cancelled state.
     */
    public boolean isPaused() {
        return isPaused;
    }

    public void setPaused(boolean pause) {
        if (line != null) {
            if (pause) {
                isPaused = true;
                exitRequested = true;
            } else {
                isPaused = false;
                exitRequested = false;
            }
        }
    }

    public void cancel() {
        isPaused = false;
        exitRequested = true;
        isCancelled = true;
    }

    public boolean isCancelled() {
        return isCancelled;
    }

    public SourceDataLine getLine() {
        return line;
    }

    public void close() {
        if (line != null) {
            line.close();
        }
    }

    @Override
    protected void finalize() throws Throwable {
        close();
    }



    /**
     * Lines can fail to open because they are already in use.
     * Java sound uses OSS and some linuxes are using pulseaudio.
     * OSS needs exclusive access to the line, and pulse audio
     * highjacks it. Try to open another line.
     * @param format
     * @return a open line
     * @throws IllegalStateException if it can't open a dataline for the
     * audioformat.
     */
    private SourceDataLine getSourceDataLine(AudioFormat format) {
        Exception audioException = null;
        try {
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
            Mixer.Info [] arr = AudioSystem.getMixerInfo();
            Arrays.sort(arr, new Comparator() {

                public int compare(Object o1, Object o2) {
                    Mixer.Info m1 = (Info) o1;
                    Mixer.Info m2 = (Info) o2;
                    if("Java Sound Audio Engine".equals(m1.getName()))
                        return -1;
                    if("Java Sound Audio Engine".equals(m2.getName()))
                        return 1;
                    return 0;
                }
            });

            for (Mixer.Info mi : arr) {
                SourceDataLine dataline = null;
                try {
                               
                    Mixer mixer = AudioSystem.getMixer(mi);
                    dataline = (SourceDataLine) mixer.getLine(info);
                    dataline.open(format);
                    dataline.start();
                  System.out.println(mi.getName());
                    return dataline;
                } catch (Exception e) {
                    audioException = e;
                }
                if (dataline != null) {
                    try {
                        dataline.close();
                    } catch (Exception e) {
                    }
                }
            }
        } catch (Exception e) {
            throw new IllegalStateException("Error trying to aquire dataline.", e);
        }
        if (audioException == null) {
            throw new IllegalStateException("Couldn't aquire a dataline, this computer doesn't seem to have audio output?");
        } else {
            throw new IllegalStateException("Couldn't aquire a dataline, probably because all are in use. Last exception:", audioException);
        }
    }

    public void run() {
        status = Status.PLAYING;
        isCancelled = false;
        AudioFormat audioFormat = ais.getFormat();

        DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);

        try {
            if (line == null) {
                boolean bIsSupportedDirectly = AudioSystem.isLineSupported(info);
                if (!bIsSupportedDirectly) {
                    AudioFormat sourceFormat = audioFormat;
                    AudioFormat targetFormat = new AudioFormat(
                            AudioFormat.Encoding.PCM_SIGNED,
                            sourceFormat.getSampleRate(),
                            sourceFormat.getSampleSizeInBits(),
                            sourceFormat.getChannels(),
                            sourceFormat.getChannels() * (sourceFormat.getSampleSizeInBits() / 8),
                            sourceFormat.getSampleRate(),
                            sourceFormat.isBigEndian());
                    ais = AudioSystem.getAudioInputStream(targetFormat, ais);
                    audioFormat = ais.getFormat();
                }
                line = getSourceDataLine(audioFormat);
                if (lineListener != null) {
                    line.addLineListener(lineListener);
                }
            }
            line.open(audioFormat);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }

        int nRead = 0;
        byte[] abData = new byte[1056]; // needs to be a multiple of 4 and 6, to support both 16 and 24 bit stereo

        boolean startResume;
        do {
            startResume = false;
            line.start();
            while (nRead != -1 && !exitRequested) {
                try {
                    nRead = ais.read(abData, 0, abData.length);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (nRead >= 0) {
                    line.write(abData, 0, nRead);
                }
            }

            if (exitRequested && !isPaused) {
                //cancel
                line.stop();
                line.flush();
            } else if (isPaused) {
                line.stop();
                line.drain();
                try {
                    while (isPaused) {
                        Thread.sleep(20);
                    }
                    startResume = true;
                } catch (InterruptedException ex) {
                    //if interrupted...
                    cancel();
                }
            }

            if (!exitRequested) {
                line.drain();
            }
            //System.out.println("EXITREQ " + exitRequested + " RESUME " + startResume + " IS PAUSED " + isPaused);
        } while (startResume);
        exitRequested = false;
        status = Status.WAITING;
    }
}



Re: <Sound Dev> sound on Linux

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This way still conflicts with ALSA-based players... and probably with any other sound players.. In comments i saw that Java uses OSS for sound output? I think this is a root cause.. This looks it is the same that no sound at Linux...

2009/10/14 Paulo Levi <i30817@...>
Try to make the default engine the java audio engine... I think i had
a test case to see if it worked around here... replace the string for
the wav file, and also, probably the "Java Sound Audio Engine" is not
the correct name string in the comparator ... you'll have to see. I
can't test this now since i don't have a linux here this fails handy.



Re: <Sound Dev> sound on Linux

by Peter Salomonsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

If you rather use OpenJDK instead of Sun's, then you can use pulseaudio for playback. Actually pulseaudio is default audio output for OpenJDK on ubuntu linux. Then it's no problem with audio output from multiple applications simultaneously..

regards,

Peter

2009/10/14 cyberGn0m <cy6ergn0m@...>
This way still conflicts with ALSA-based players... and probably with any other sound players.. In comments i saw that Java uses OSS for sound output? I think this is a root cause.. This looks it is the same that no sound at Linux...

2009/10/14 Paulo Levi <i30817@...>
Try to make the default engine the java audio engine... I think i had

a test case to see if it worked around here... replace the string for
the wav file, and also, probably the "Java Sound Audio Engine" is not
the correct name string in the comparator ... you'll have to see. I
can't test this now since i don't have a linux here this fails handy.




Re: <Sound Dev> sound on Linux

by PJ leonard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My understanding is:

mplayer might use pulseaudio which allows the sharing of the soundoutput (on my ubuntu this is the default)
JAVA uses the alsa device directly so it can not be used by other applications.
iced tea JAVA does have a pulseaudio device but I can only produce broken up sound using this.

Paul.

2009/10/13 cyberGn0m <cy6ergn0m@...>
Anybody tested java sound on linux? As I know, java uses ALSA on Linux to play audio.. so, i have a problem with it: when java plays sound, other applications can't play anything. When other applications plays sound, java can't. As i know, mplayer can play sound via ALSA and i can open many players and all of them will plays as expected...




Re: <Sound Dev> sound on Linux

by Bugzilla from rom1dep@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/13 cyberGn0m <cy6ergn0m@...>

Anybody tested java sound on linux? As I know, java uses ALSA on Linux to play audio.. so, i have a problem with it: when java plays sound, other applications can't play anything. When other applications plays sound, java can't. As i know, mplayer can play sound via ALSA and i can open many players and all of them will plays as expected...


Yepp, I have this problem too and this is very annoying. I found this bug : http://bugs.sun.com/view_bug.do?bug_id=6832063
but I was asking me recently whether or not the fix is really in progress. This issue has made us (people working on the XtremeMP media player) think on a fallback audio backend based on gstreamer-java for people running under linux

If you rather use OpenJDK instead of Sun's, then you can use pulseaudio for playback. Actually pulseaudio is default audio output for OpenJDK on ubuntu linux. Then it's no problem with audio output from multiple applications simultaneously..

Are you sure ? I use OpenJDK 1.7.0b70 and can't have amarok (gstreamer->PulseAudio) and XtremeMP playing simultaneously on my netbook. Maybe your hardware has some mixing abilities that lets your 'normal' programs play through pulseaudio over a stream while another one is available for java ? You can try this : play something with mplayer or whatever grinding PA, + trying to play a wave file with "aplay <file.wav>". If you have your two streams being played, then your audio card is likely mixing-capable...



Re: <Sound Dev> sound on Linux

by Peter Salomonsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Yes, I'm sure:

This is run on an out-of-the-box ubuntu installation:

public static void main(String[] args) throws Exception {
        Clip clip = AudioSystem.getClip();
        clip.open(AudioSystem.getAudioInputStream(new File("test.wav")));
        clip.start();
        while(true)
            Thread.sleep(1);
    }

Plays without problems, and I can also call with skype simultaneously (and other pulseaudio supporting apps).

As for Frinika - the sound produced from this app is choppy as Paul said - but this is a problem with Frinika and not the pulseaudio support in openjdk..

regards,

Peter

2009/10/14 rom1dep <rom1dep@...>
2009/10/13 cyberGn0m <cy6ergn0m@...>

Anybody tested java sound on linux? As I know, java uses ALSA on Linux to play audio.. so, i have a problem with it: when java plays sound, other applications can't play anything. When other applications plays sound, java can't. As i know, mplayer can play sound via ALSA and i can open many players and all of them will plays as expected...


Yepp, I have this problem too and this is very annoying. I found this bug : http://bugs.sun.com/view_bug.do?bug_id=6832063
but I was asking me recently whether or not the fix is really in progress. This issue has made us (people working on the XtremeMP media player) think on a fallback audio backend based on gstreamer-java for people running under linux


If you rather use OpenJDK instead of Sun's, then you can use pulseaudio for playback. Actually pulseaudio is default audio output for OpenJDK on ubuntu linux. Then it's no problem with audio output from multiple applications simultaneously..

Are you sure ? I use OpenJDK 1.7.0b70 and can't have amarok (gstreamer->PulseAudio) and XtremeMP playing simultaneously on my netbook. Maybe your hardware has some mixing abilities that lets your 'normal' programs play through pulseaudio over a stream while another one is available for java ? You can try this : play something with mplayer or whatever grinding PA, + trying to play a wave file with "aplay <file.wav>". If you have your two streams being played, then your audio card is likely mixing-capable...




Re: <Sound Dev> sound on Linux

by Alex Menkov-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


rom1dep wrote:

>     2009/10/13 cyberGn0m <cy6ergn0m@... <mailto:cy6ergn0m@...>>
>         Anybody tested java sound on linux? As I know, java uses ALSA on
>         Linux to play audio.. so, i have a problem with it: when java
>         plays sound, other applications can't play anything. When other
>         applications plays sound, java can't. As i know, mplayer can
>         play sound via ALSA and i can open many players and all of them
>         will plays as expected...
> Yepp, I have this problem too and this is very annoying. I found this
> bug : http://bugs.sun.com/view_bug.do?bug_id=6832063
> but I was asking me recently whether or not the fix is really in
> progress. This issue has made us (people working on the XtremeMP media
> player) think on a fallback audio backend based on gstreamer-java for
> people running under linux

The bug is fixed in 6-open, but the fix is still not integrated into jdk7.

Regards
Alex

>     If you rather use OpenJDK instead of Sun's, then you can use
>     pulseaudio for playback. Actually pulseaudio is default audio output
>     for OpenJDK on ubuntu linux. Then it's no problem with audio output
>     from multiple applications simultaneously..
> Are you sure ? I use OpenJDK 1.7.0b70 and can't have amarok
> (gstreamer->PulseAudio) and XtremeMP playing simultaneously on my
> netbook. Maybe your hardware has some mixing abilities that lets your
> 'normal' programs play through pulseaudio over a stream while another
> one is available for java ? You can try this : play something with
> mplayer or whatever grinding PA, + trying to play a wave file with
> "aplay <file.wav>". If you have your two streams being played, then your
> audio card is likely mixing-capable...


Re: <Sound Dev> sound on Linux

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I run mplayer in "alsa" mode and many mplayer's can play sound at the same time in this mode. Java uses ALSA too, but it gets exclusive access to audio device...

2009/10/14 PJ leonard <pauljohnleonard@...>
My understanding is:

mplayer might use pulseaudio which allows the sharing of the soundoutput (on my ubuntu this is the default)
JAVA uses the alsa device directly so it can not be used by other applications.
iced tea JAVA does have a pulseaudio device but I can only produce broken up sound using this.

Paul.

2009/10/13 cyberGn0m <cy6ergn0m@...>

Anybody tested java sound on linux? As I know, java uses ALSA on Linux to play audio.. so, i have a problem with it: when java plays sound, other applications can't play anything. When other applications plays sound, java can't. As i know, mplayer can play sound via ALSA and i can open many players and all of them will plays as expected...






--
-----------------------------------------------------------------
Всего наилучшего

                         <y6erGn0m.

Re: <Sound Dev> sound on Linux

by i30817 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So this is only fixed on openjdk? No code level work around for lower versions?

On Thu, Oct 15, 2009 at 8:24 AM, cyberGn0m <cy6ergn0m@...> wrote:

> I run mplayer in "alsa" mode and many mplayer's can play sound at the same
> time in this mode. Java uses ALSA too, but it gets exclusive access to audio
> device...
>
> 2009/10/14 PJ leonard <pauljohnleonard@...>
>>
>> My understanding is:
>>
>> mplayer might use pulseaudio which allows the sharing of the soundoutput
>> (on my ubuntu this is the default)
>> JAVA uses the alsa device directly so it can not be used by other
>> applications.
>> iced tea JAVA does have a pulseaudio device but I can only produce broken
>> up sound using this.
>>
>> Paul.
>>
>> 2009/10/13 cyberGn0m <cy6ergn0m@...>
>>>
>>> Anybody tested java sound on linux? As I know, java uses ALSA on Linux to
>>> play audio.. so, i have a problem with it: when java plays sound, other
>>> applications can't play anything. When other applications plays sound, java
>>> can't. As i know, mplayer can play sound via ALSA and i can open many
>>> players and all of them will plays as expected...
>>>
>>>
>>
>
>
>
> --
> -----------------------------------------------------------------
> Всего наилучшего
>
>                          <y6erGn0m.
>

Re: <Sound Dev> sound on Linux

by Bugzilla from rom1dep@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/14 Alex Menkov <alex.menkov@...>

rom1dep wrote:
   2009/10/13 cyberGn0m <cy6ergn0m@... <mailto:cy6ergn0m@...>>

       Anybody tested java sound on linux? As I know, java uses ALSA on
       Linux to play audio.. so, i have a problem with it: when java
       plays sound, other applications can't play anything. When other
       applications plays sound, java can't. As i know, mplayer can
       play sound via ALSA and i can open many players and all of them
       will plays as expected...
Yepp, I have this problem too and this is very annoying. I found this bug : http://bugs.sun.com/view_bug.do?bug_id=6832063
but I was asking me recently whether or not the fix is really in progress. This issue has made us (people working on the XtremeMP media player) think on a fallback audio backend based on gstreamer-java for people running under linux

The bug is fixed in 6-open, but the fix is still not integrated into jdk7.

Regards
Alex
 
Ok, that fits with the behavior I encounter... Do you know when the fix will be applied into jdk7 ? That shouldn't be that hard if the work has already been done for openjdk6 :)

Then, have a nice WE !

Romain.