Add pulseaudio support to sun-java6-jdk

Bug #457144 reported by Antti S. Lankila on 2009-10-21
98
This bug affects 19 people
Affects Status Importance Assigned to Milestone
openjdk-8 (Ubuntu)
Undecided
Unassigned
Nominated for Karmic by Francesco Pretto
Nominated for Lucid by Francesco Pretto
sun-java6 (Ubuntu)
Undecided
Unassigned
Nominated for Karmic by Francesco Pretto
Nominated for Lucid by Francesco Pretto

Bug Description

OpenJDK for amd64 contains the following files:

./jre/lib/amd64/libpulse-java.so
./jre/lib/ext/pulse-java.jar

and a sound.properties file with this:

# OpenJDK on Ubuntu is configured to use PulseAudio by default
javax.sound.sampled.Clip=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.Port=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.SourceDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
javax.sound.sampled.TargetDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider

Copying the files above from openjdk to sun jdk and these rows to sound.properties seems to turn java6 jdk pulseaudio aware. It'd be great to see future versions of the package do this automatically.

The following is not related to the bug but describes my motivation. I need to do this because I don't get sound with OSS or ALSA applications because of routing problems with optical connection from Audigy 2 ZS that's somehow related to pulseaudio but undebugable for me. It is related to the "Optical Raw" switch, which I could toggle in the past to get alsa and oss sound working again over the digital output. However, in the karmic betas this setting can no longer be toggled with alsamixer, and thus I *must* have audio routed via pulseaudio to hear anything at all.

ProblemType: Bug
Architecture: amd64
Date: Wed Oct 21 15:26:34 2009
DistroRelease: Ubuntu 9.10
NonfreeKernelModules: nvidia
Package: sun-java6-jdk 6-15-1
ProcEnviron:
 PATH=(custom, user)
 LANG=fi_FI.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-14.48-generic
SourcePackage: sun-java6
Uname: Linux 2.6.31-14-generic x86_64

Antti S. Lankila (alankila) wrote :
Robert W. Brewer (rwb123) wrote :

The workaround did add pulse support to a simple test app I had. It didn't ultimately work for my Sphinx4 speech recognition app however, so I had to revert to using Sun's JVM and ALSA.

Changed in sun-java6 (Ubuntu):
status: New → Confirmed

Francesco, could you try to create an /etc/asound.conf file like the one here: http://pulseaudio.org/wiki/PerfectSetup#ALSAApplications
In terminal:
gksu gedit /etc/asound.conf

Then copy and paste the code below into the file. Save, quit, and reboot. See if alsa apps works properly now:
pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

Francesco Pretto (ceztko) wrote :

Hello. Sorry, I forgot to subscribe to this bug so I lost your update. Tried your hint and no joy.

I usually test this problem with browser and this java web radio: http://rob.kohina.net/javastream

Close browser -> open browser -> open java web radio -> open any youtube video -> NO sound on youtube.

Close browser -> open browser -> open any youtube video -> open java web radio -> NO sound on java web radio.

manolo (manuel-sales) wrote :

Francesco, thanks for the advice.

The good news is that if I follow your advice it works (just copying libpulse-java.so and pulse-java.jar is enough, even if I don't modify sound.properties it also works), I can play your web radio at the same time I play music with Rhythmbox

The bad news is that not everything works..

1) a java program not done by me, it works the first time a sound is played (but an icon that should change to pause after the sound is played never changes) and the second time it tryes to play the application gets frozen (I suppose the first sound never acknowledges that it has finished and some kind of lock occurs) and the only way out is to kill it.
The terminal shows this stack trace
PulseAudio Eventloop Thread
 at java.lang.Object.wait(Native Method)
 at java.lang.Thread.join(Thread.java:1143)
 at java.lang.Thread.join(Thread.java:1196)
 at org.classpath.icedtea.pulseaudio.PulseAudioClip.close(PulseAudioClip.java:247)
 at jsound.b.f(b.java:112)
 at jsound.b.update(b.java:69)
 at org.classpath.icedtea.pulseaudio.PulseAudioLine.fireLineEvent(PulseAudioLine.java:76)
 at org.classpath.icedtea.pulseaudio.PulseAudioDataLine$2.update(PulseAudioDataLine.java:207)
 at org.classpath.icedtea.pulseaudio.Stream.underflowCallback(Stream.java:601)
 at org.classpath.icedtea.pulseaudio.EventLoop.native_iterate(Native Method)
 at org.classpath.icedtea.pulseaudio.EventLoop.run(EventLoop.java:141)
 at java.lang.Thread.run(Thread.java:619)
2) A program done by me plays the sound the first time but the second not; in this case my application doesnt throw any error and there is no stack trace; anyway it seems similar to case 1.
In this case the code I wrote for the defining and loading the sound is...
    try {

      // especificar el sonido a tocar

      soundFile = new File(c.carpetaDatos + "CconfCV.wav");

      sound = AudioSystem.getAudioInputStream(soundFile); //throws UnsupportedAudioFileException, IOException

      // cargar el sonido en memoria (un Clip)

      clipConfCV = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, sound.getFormat()));
      clipConfCV.open(sound);

    } catch (javax.sound.sampled.UnsupportedAudioFileException ex) {

       c.t.traza('E', "Aplicacion", "UnsupportedAudioFileException: en sonido " + soundFile, true, false);

    } catch (java.io.IOException ex) {

       c.t.traza('E', "Aplicacion", "IOException: en sonido " + soundFile, true, false);

    } catch (javax.sound.sampled.LineUnavailableException ex) {

       c.t.traza('E', "Aplicacion", "LineUnavailableException: en sonido " + soundFile, true, false);

    }

  }

And the method for playing...
  public void ReproduceSonido(int sonido) {

    clipConfCV.setFramePosition(0); clipConfCV.start();
  }

2010/5/8 manolo <email address hidden>:
> Francesco, thanks for the advice.
>

Wasn't my advice, but Antti's one. Anyway, it seems sun official jvm
isn't going to be supported long (it's have been removed from lucid
main repositories), so it's better to begin reporting bugs with
openjdk where hopefully integration with pulseaudio works better.

I have a workaround (found on this site: http://www.tuxyturvy.com/blog/index.php?url=archives/66-Making-Sun-Java-1.6-play-via-PulseAudio.html#feedback ) to get java sound to "use" pulseaudio

Rename your existing java executable to java.bin and drop an executable script called java in the directory with the following content:

#!/bin/bash
padsp /usr/lib/jvm/java-6-sun/jre/bin/java.bin "$@"

Now I can run my audio player (rhythmbox) and play audio through my java application (java sound)

Rob Frohne (frohro) wrote :

Hi All,

I don't know how I missed this bug report when I made this one:

https://bugs.launchpad.net/ubuntu/+source/sun-java6/+bug/685125

Anyway, there is a patch included in that one that solves the problem nicely.

The maintainers seem reluctant to include it in the distribution, because it isn't totally clear if patches to sunjava6 are allowed. I think they are based on the license saying that the README files contain the details about what can be and can't be patched, and based on the README content, however, I'm not a lawyer or the maintainer, so my opinion probably doesn't count.

Rob

Sylvestre Ledru (sylvestre) wrote :

Rob, I am sorry but there is no way we would do something like you are proposing in bug 685125.

I see (at least) two blocking reasons:
* OpenJDK is GPL while sun-java-6 is not at all (it is proprietary). This would violate the GPL.
* You are coping binary from a package to other without any certitude about the binary compatibility. (this work would requires a total synchronization between the openjdk and proprietary on the packaging side which does not exist at all).

This should probably be marked as Won't Fix since Ubuntu is no longer licensed to distribute Sun/Oracle Java.

Changed in sun-java6 (Ubuntu):
status: Confirmed → Won't Fix
Václav Šmilauer (eudoxos) wrote :

Just for the record, this seems to be broken still (2015) with Oracle's Java. Happy customers are the most important thing...?!

wolfger (wolfger) wrote :

LOL

Tiago Stürmer Daitx (tdaitx) wrote :

Unfortunately, we cannot work on this bug because your description didn't include enough information on how this affects OpenJDK-8. We'd be grateful if you would then provide a more complete description of the problem. For now settings this as invalid for OpenJDK-8.

Changed in openjdk-8 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers