Bug 26339 - Problems using javax.sound
Summary: Problems using javax.sound
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.20
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-17 13:26 UTC by Panagiotis Issaris
Modified: 2012-01-10 15:56 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-02-18 00:20:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Panagiotis Issaris 2006-02-17 13:26:27 UTC
I have been investigating using Oscar's OSGi implementation. One of the jars which provides MP3 playback works fine on Sun's JVM, but I couldn't get it to work when using JamVM with GNU Classpath. 
So, either JamVM or GNU Classpath or both are causing it to fail.

The following lines show the output when using the Sun JVM and Sun Java
class libraries on my PC:
-> mp3 play file:/tmp/test.mp3
-> Play started from frame 0
-> mp3 stop
Play completed at frame 15087

All working fine. No exceptions and it plays the music as it should.

Next, the following lines show the output when using the JamVM JVM and
the GNU Classpath class libraries on my PC:
-> mp3 play file:/tmp/test.mp3
javax.sound.sampled.LineUnavailableException: no Clip available
   at javax.sound.sampled.AudioSystem.getLine (AudioSystem.java:387)
   at javazoom.jl.player.JavaSoundAudioDevice.createSource
(JavaSoundAudioDevice.java:101)
   at javazoom.jl.player.JavaSoundAudioDevice.writeImpl
(JavaSoundAudioDevice.java:148)
   at javazoom.jl.player.AudioDeviceBase.write
(AudioDeviceBase.java:133)
   at javazoom.jl.player.JavaSoundAudioDevice.test
(JavaSoundAudioDevice.java:205)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.testAudioDevice
(JavaSoundAudioDeviceFactory.java:83)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.createAudioDevice
(JavaSoundAudioDeviceFactory.java:42)
   at javazoom.jl.player.FactoryRegistry.createAudioDevice
(FactoryRegistry.java:87)
   at javazoom.jl.player.advanced.AdvancedPlayer.<init>
(AdvancedPlayer.java:66)
   at javazoom.jl.player.advanced.AdvancedPlayer.<init>
(AdvancedPlayer.java:58)
   at insa.mp3.PlayerActivator.playMp3 (PlayerActivator.java:130)
   at insa.mp3.PlayerActivator.execute (PlayerActivator.java:94)
   at org.ungoverned.osgi.bundle.shell.Activator
$ShellServiceImpl.executeCommand (Activator.java:280)
   at org.ungoverned.osgi.bundle.shelltui.ShellTuiActivator
$ShellTuiRunnable.run (ShellTuiActivator.java:172)
   at java.lang.Thread.run (Thread.java:674)

Total failure! :-/


Next I tried getting the MP3-playback run using the GNU Java
interpreter (GIJ 4.0). As this one uses GNU Classpath too, it might help me determine whether it was JamVM or GNU Classpath that caused it to fail.


->  mp3 play file:/tmp/test.mp3
java.lang.NoClassDefFoundError: while resolving class:
javazoom.jl.player.JavaSoundAudioDevice
   at java.lang.VMClassLoader.transformException(java.lang.Class,
java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
   at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/usr/lib/libgcj.so.6.0.0)
   at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
   at java.lang.Class.newInstance() (/usr/lib/libgcj.so.6.0.0)
   at
javazoom.jl.player.AudioDeviceFactory.instantiate(java.lang.ClassLoader,
java.lang.String) (Unknown Source)
   at
javazoom.jl.player.JavaSoundAudioDeviceFactory.createAudioDeviceImpl()
(Unknown Source)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.testAudioDevice()
(Unknown Source)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.createAudioDevice()
(Unknown Source)
   at javazoom.jl.player.FactoryRegistry.createAudioDevice() (Unknown
Source)
   at
javazoom.jl.player.advanced.AdvancedPlayer.AdvancedPlayer(java.io.InputStream, javazoom.jl.player.AudioDevice) (Unknown Source)
   at
javazoom.jl.player.advanced.AdvancedPlayer.AdvancedPlayer(java.io.InputStream) (Unknown Source)
   at insa.mp3.PlayerActivator.playMp3(java.lang.String) (Unknown
Source)
   at insa.mp3.PlayerActivator.execute(java.lang.String,
java.io.PrintStream, java.io.PrintStream) (Unknown Source)
   at org.ungoverned.osgi.bundle.shell.Activator
$ShellServiceImpl.executeCommand(java.lang.String, java.io.PrintStream,
java.io.PrintStream) (Unknown Source)
   at org.ungoverned.osgi.bundle.shelltui.ShellTuiActivator
$ShellTuiRunnable.run() (Unknown Source)
   at java.lang.Thread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException:
javax.sound.sampled.AudioFormat
   at
org.ungoverned.moduleloader.ModuleClassLoader.findClass(java.lang.String) (Unknown Source)
   at
org.ungoverned.moduleloader.ModuleClassLoader.loadClass(java.lang.String, boolean) (Unknown Source)
   at java.lang.ClassLoader.loadClass(java.lang.String)
(/usr/lib/libgcj.so.6.0.0)
   ...15 more

And as can be seen, it fails with GIJ 4.0 too.

I'm not sure if I can conclude that GNU Classpath is at fault because the reported problems are not the same. So, it might be two different bugs, or one bug being triggered in different ways or one bug being reported differently because of using different JVMs... I don't really know...

The system I'm running this on:
Ubuntu Breezy (5.10) with GNU Classpath 0.20, JamVM 1.4.1 and GNU gij 4.0.2 20050808 all on an x86 (P4).

Originally I encountered the MP3 playback error when trying to run Oscar on JamVM with GNU Classpath 0.19 on my Nokia 770 Linux based device (TI OMAP).

With friendly regards,
Takis
Comment 1 Panagiotis Issaris 2006-02-17 13:31:14 UTC
If you've got JamVM and Oscar installed you can reproduce it by using a few commands:
jamvm -jar lib/oscar.jar
orb install "MP3 Player"
start 5
mp3 play file:/tmp/test.mp3


Which in more detail with Oscar's output will look like this:
takis@zeus:/opt/Oscar$ jamvm -jar lib/oscar.jar

Welcome to Oscar.
=================

Enter profile name: takis

-> obr install "MP3 Player"
Installing: MP3 Player
-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.0.5)
[   1] [Active     ] [    1] Shell Service (1.0.2)
[   2] [Active     ] [    1] Shell TUI (1.0.0)
[   3] [Active     ] [    1] Bundle Repository (1.1.2)
[   4] [Installed  ] [    1] mp3 player (0.0.2)
-> start 4
A new command has been installed
mp3 play|stop <stream URL>
Ex : mp3 play http://sofsis.cl:8000/128.mp3
Ex : mp3 play file:/opt/mp3player/test.mp3
-> mp3 play file:/tmp/test.mp3
javax.sound.sampled.LineUnavailableException: no Clip available
   at javax.sound.sampled.AudioSystem.getLine (AudioSystem.java:387)
   at javazoom.jl.player.JavaSoundAudioDevice.createSource (JavaSoundAudioDevice.java:101)
   at javazoom.jl.player.JavaSoundAudioDevice.writeImpl (JavaSoundAudioDevice.java:148)
   at javazoom.jl.player.AudioDeviceBase.write (AudioDeviceBase.java:133)
   at javazoom.jl.player.JavaSoundAudioDevice.test (JavaSoundAudioDevice.java:205)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.testAudioDevice (JavaSoundAudioDeviceFactory.java:83)
   at javazoom.jl.player.JavaSoundAudioDeviceFactory.createAudioDevice (JavaSoundAudioDeviceFactory.java:42)
   at javazoom.jl.player.FactoryRegistry.createAudioDevice (FactoryRegistry.java:87)
   at javazoom.jl.player.advanced.AdvancedPlayer.<init> (AdvancedPlayer.java:66)
   at javazoom.jl.player.advanced.AdvancedPlayer.<init> (AdvancedPlayer.java:58)
   at insa.mp3.PlayerActivator.playMp3 (PlayerActivator.java:130)
   at insa.mp3.PlayerActivator.execute (PlayerActivator.java:94)
   at org.ungoverned.osgi.bundle.shell.Activator$ShellServiceImpl.executeCommand (Activator.java:280)
   at org.ungoverned.osgi.bundle.shelltui.ShellTuiActivator$ShellTuiRunnable.run (ShellTuiActivator.java:172)
   at java.lang.Thread.run (Thread.java:674)

The file is indeed accessible as can be seen: If the file is non-existing it goes like this:
-> mp3 play file:/tmp/void.mp3
java.io.FileNotFoundException: No such file or directory: /tmp/void.mp3
   at gnu.java.nio.channels.FileChannelImpl.open (Native Method)
   at gnu.java.nio.channels.FileChannelImpl.<init> (FileChannelImpl.java:124)
   at gnu.java.nio.channels.FileChannelImpl.create (FileChannelImpl.java:116)
   at java.io.FileInputStream.<init> (FileInputStream.java:110)
   at gnu.java.net.protocol.file.Connection.connect (Connection.java:191)
   at gnu.java.net.protocol.file.Connection.getInputStream (Connection.java:251)
   at java.net.URL.openStream (URL.java:684)
   at insa.mp3.PlayerActivator.playMp3 (PlayerActivator.java:123)
   at insa.mp3.PlayerActivator.execute (PlayerActivator.java:94)
   at org.ungoverned.osgi.bundle.shell.Activator$ShellServiceImpl.executeCommand (Activator.java:280)
   at org.ungoverned.osgi.bundle.shelltui.ShellTuiActivator$ShellTuiRunnable.run (ShellTuiActivator.java:172)
   at java.lang.Thread.run (Thread.java:674)



With friendly regards,
Takis
Comment 2 Panagiotis Issaris 2006-02-17 15:45:48 UTC
Okay, I think I figured out what the problem is as the GNU Classpath task pages states:
"We don't have a provider for javax.sound.sampled. Perhaps we could have one based on Jack or GStreamer."

So apparantly, it is simply not implemented yet :)

My example works fine on Kaffe, which is using Tritonus (www.tritonus.org) in addition to GNU Classpath for its Java classlibraries.

Would the GNU Classpath developers consider integrating Tritonus in GNU Classpath or are there any licensing problems (GPL+exception vs LGPL)?

Is anyone aware of anyone starting on such an implementation? If not, could anyone give some hints on what would be needed?
Comment 3 Andrew Pinski 2006-02-18 00:20:28 UTC
Confirmed.
Comment 4 Tom Tromey 2006-03-07 16:02:27 UTC
We probably won't directly incorporate Tritonus into the Classpath
release, though I don't think the idea has been fully discussed.
However we ought to work with Tritonus -- if I set it up here I can
play sounds and whatnot using jamvm+classpath+tritonus.

One idea would be to write our own back end using Jack or GStreamer
or the like.  As far as I know nobody is actively working on this
at the moment.
Comment 5 Andrew John Hughes 2007-11-01 08:59:04 UTC
Can you test this with the latest Classpath release with the experimental GStreamer peer enabled (--with-gstreamer-peer)?  There's not enough information in this bug report to replicate the bug easily.
Comment 6 Richard Biener 2012-01-10 15:56:09 UTC
Assuming fixed.