JavaSound on Linux

@nsigma:
Well, that’s cool beans, because I come into contact with Flash all the time. Also, having to tell users to avoid Flash if they want sound doesn’t sound fun.

As a general update, I’ve tried out Paul’s library. As expected, using it with OpenAL works perfectly without trouble. However, if I use the JavaSound part of Paul’s library, I get the exact same problems as before: No sound whatsoever with the Sun/Oracle JDK, and slow/error-prone sound with OpenJDK. I guess I can try some of the other suggested libraries later, but at this point, I don’t see how that would change things. To be honest, I’m getting extremely annoyed with this. I mean, what’s the point of trying to do something like software mixing or using another library if I can’t get a single sound out of the Sun/Oracle JDK at all? I’m not trying to do anything fancy, like opening multiple lines or anything. I tested each of the available mixers by getting a single line from the mixer and trying to play one .wav file with that. Half of them crashed with an exception with even the most basic .wav file (unsupported format - well, what format is supported, then?), while the other half just didn’t do anything. The fact that I do get sound with OpenJDK seems to be related to the missing mixers after all - Google found me this link: http://mail.openjdk.java.net/pipermail/sound-dev/2011-May/000115.html, which indicates that with the Sun/Oracle JDK, JavaSound does not seem to provide any mixers on Linux that work reliably. The “Java Sound Audio Engine” mixer, which I’ve also seen mentioned sometimes, doesn’t even seem to exist on my machine.

Really, it’s going to take a lot to convince me that JavaSound on Linux is not completely worthless. Actually, it would help if anyone could post a tiny bit of example code that plays a sound on Linux with the Oracle/Sun JDK, because I haven’t seen that yet. In particular, it would help because I’m still not sure if I’m using the API the “right” way, since one apparently has to follow a bunch of obscure, undocumented rules to do anything with JavaSound/Linux.

“they call me dava ja vu they do they call me dave ja vu” :smiley:

Well, you could try out the audio examples in Praxis (link in sig - also see JAudioLibs thread linked above), but I don’t think this would class as a lightweight example! I’d still be interested to know if it has the same issue mind you … :slight_smile:

The best bet is probably to try the JSInfo applet / application at http://www.jsresources.org/apps/jsinfo.html. The applet should be fine for testing output, though doesn’t give you access to all of JavaSound (eg. input needs security permissions). Not only does this allow you to query all the mixers, it gives you a GUI for running through all the various line open permutations with test sound output and will tell you of any errors. Source code for it is available, and there are some other simple audio examples on that site.

The message you linked to highlights the issue that Java (Oracle one) always wants to open the soundcard exclusively - Flash used to be (sometimes still is?) the same. It is highly likely that you’ve got another application accessing the soundcard (try switching off any sound theme for the desktop, checking for any audio apps in system tray, and possibly killing pulseaudio too and see if that helps at all). This is the reason a PulseAudio mixer was added to OpenJDK - not sure if that made its way into Java 7?! Personally, I find PulseAudio to be more trouble than it’s worth most of the time though.

@nsigma:
At first, I was like “what the heck are you talking about?”, then I looked at my post and went “how did THAT happen?”.

Anyway, I’m kind of shocked. The Audio example in Praxis seems to work without any trouble at all, even while playing Flash videos at the same time. How did you do that? Does it use anything else other than JavaSound for audio output? If not, I think I’ll take a very close look at Praxis/JAudioLibs after all.

As for the JSInfo applet, that is indeed useful, especially if you have no idea what the mixers are actually supposed to do (input or output) (like me). I couldn’t get sound output to work with that, but the GUI confused me a little, so I might’ve been doing it wrong.

Regarding the PulseAudio mixer, I already seem to have that with OpenJDK 6 (-> first post). OpenJDK also has the “default” ALSA mixer mentioned in the link I posted, which doesn’t seem to lock the soundcard exclusively and which apparently does work (even on my machine), so even if you don’t like PulseAudio, I don’t see why this shouldn’t be included in both JDKs, as it seems to be (almost?) the only reliable way. Now, of course I could try to close everything I have running, kill PulseAudio and so on and perhaps eventually get sound output with one of the mixers even with the Sun/Oracle JDK, but I can’t expect my users to do the same thing. There really needs to be a way to output sound without having to impose any kind of ridiculous, strict set of rules on the users, otherwise they’re just not going to bother, even if it’s not really the developer’s fault.

Well, that’s good to know, though also intriguing! If you’re not using the JACK output (and it’s not set up to by default) then Praxis is just using JavaSound. You can see how the lines are set up in the initialise() and runImpl() methods here - http://code.google.com/p/praxis/source/browse/audio.servers.javasound/src/org/jaudiolibs/audioservers/javasound/JavasoundAudioServer.java

Couple of other things that Praxis might be doing differently -

  • Praxis is currently set up to always open input lines as well (I doubt this is your issue).
  • Praxis always iterates through the mixers to find one that supports output lines. See the find…Mixer() methods in the above class. I wonder if it’s possible that you’re experiencing the same issue that gouessej has with JavaSound picking a soundcard (webcam) that is input only. Although I think you said you’d tried all mixers?

It’s not easy to find your way around, that’s for sure! Use the “Line Lifecycle” tab, and click Line [create -> open -> start] and then Data [start]. There doesn’t seem to be a way to select a particular mixer for this though.

Don’t get me wrong, I’d like to see the PulseAudio mixer and an up-to-date ALSA mixer in the standard Oracle JDK, and I wonder whether it’s made it in to 7 (not looked yet). It’s just that I’ve had issues with PulseAudio in the past, and quite frankly don’t have much interest in multiple applications playing audio at the same time - I’ve only one set of ears! :slight_smile: I’m all for having the choice though.

I should point out also that on my setup I don’t have to jump through any hoops (ie. kill PulseAudio) to get Java sound - I think PulseAudio should auto-suspend when nothing is playing through it.

I’m probably going to be offline for the next week, so good luck with it!

Best wishes, Neil

Socob, you can get better results with JavaSound (and Paul Lamb Sound Library) by converting your files to another format or change the rate (or the sample size; if it is 32, set it to 16 bits). I did it for my game and now, it is … less bad, it works reliably on Oracle JVM but not completely on OpenJDK.

@nsigma (even if you’re offline :wink: ):
I have the suspicion that Praxis might perhaps be started with OpenJDK instead of the Sun/Oracle JVM for some reason on my computer. I started it with the launch script in the “bin” directory, so I don’t really know what it’s doing, and I haven’t found another way to launch it. Still looking into the code, regardless. Also, PulseAudio does auto-suspend if nothing is playing - it’s been enough for me to just get rid of every application that’s even remotely related to sound, mainly Firefox/Flash, and then JavaSound actually manages to work even with the Oracle JVM (which doesn’t help much, of course).

@gouessej:
So, you mean you can play sounds with the Oracle JVM on Linux even if you have, say, a Flash video playing at the same time? That would be strange, because OpenJDK seems to work a lot better for me, and as I said, I can’t get sound with the Oracle JVM at all if something else is using sound at the same time. As for the file format, I’m basically already using the most simple file sound format there is. As I wrote in the first post, I’m trying to play uncompressed 44100 Hz, 16bit signed, mono/stereo .wav files, so I don’t really know what I should change it to that would work better.

It depends on the mixer you use but relying on the availability of such a mixer is not a good idea.

Maybe Praxis is started with OpenJDK because your Linux is configured to use it by default like mine. You can try to use Praxis with Oracle JVM by modifying the script to use this JVM instead of OpenJDK.

I haven’t been on the forum in a while … I seem to have missed a really good conversation here.

[quote=“nsigma,post:14,topic:37148”]
The best solution is to do software mixing on a single line, as you’ve pointed out. Unfortunately, there is a little more to it than your characterization if you need to support pitch changes, panning, and mixing multiple formats. Sure, all those can be done as well, but then you also have to get it to run at an acceptable speed to avoid latency. Doing the mixing in native rather than pure java is really the way this should be done… OpenJDK really should ship with its own native software mixer, like the Java Sound Audio Engine.

[quote=“nsigma,post:14,topic:37148”]
Personally I wouldn’t characterize my library as working around the limitation of the API (thats kind of an oxymoron if you think about it), but rather providing a common API to access various other lower-level APIs.

I think most people here would love to simply play audio reliably. Mixing different formats in plain Java is ‘fast enough’, if you keep it at that. After we have something that works, it might be time to add features like pitch changes and panning, although I doubt many of us are even remotely interested in such features :slight_smile: => K.I.S.S.

True. I guess my perspective has always been 3D sound, which of course requires per-line changes of at least gain and pan, and preferably pitch as well.

@gouessej:
I actually have the Oracle JVM set as default for testing. I was right, however - Praxis was (for some reason) still started with OpenJDK. With the Oracle JVM, I have the same issues as before (no sound even with Praxis). So I guess I’m back at the start.

@paulscode:
Nice to have you in this thread! Your library is great (and works fine as long as I avoid JavaSound :wink: )! I’m curious, have you ever had reports of similar issues on Linux with current versions of your library, or am I the only one having these kinds of problems with JavaSound?

[quote=“paulscode,post:28,topic:37148”]
My problem with this is that I can’t even get a single line on my computer with the Oracle JVM and Linux! Well, I can, but it doesn’t do anything if anything is already playing sound. All of the available output mixers (cf. first post) on my machine are affected by this. I mean, I would consider doing software mixing, but before that, I need to be able to output sound at all.

[quote=“paulscode,post:28,topic:37148”]
Now, this is the thing: I don’t actually have any problems with sound on Linux with OpenJDK (except that methods like DataLine.stop() or DataLine.drain() take ages to return for some reason). This is because OpenJDK provides additional mixers (like the “default” mixer and the “PulseAudio” mixer). However, even with the Oracle JVM (version 6 update 26), the “Java Sound Audio Engine” mixer is not available on my machine. This only leaves me with what I assume to be mixers with direct access to the soundcard, so if I use those, I either lock up the soundcard or it is already locked, both of which is undesirable. Do you perhaps have any clue why I don’t have the “Java Sound Audio Engine” or how I could get away without using it?

[quote=“Socob,post:31,topic:37148”]
Could you post the console output you get after linking with the LibraryJavaSound plug-in and initializing the SoundSystem (using Oracle Java)?

[quote=“Socob,post:31,topic:37148”]
My own netbook (which is the only computer I have access to until I get back from this deployment) also has the “no software mixers” issue. However, unlike your situation, one of the hardware mixers does have a line available for output. Yours is the first situation I’ve heard of where none of the available mixers have any lines available for output.

[quote=“Socob,post:31,topic:37148”]

[quote=“Socob,post:31,topic:37148”]
Now that does seem very odd. I’m pretty sure the official Sun Java for Linux came with the Java Sound Audio Engine in the past, although I haven’t played around with any of the recent versions in quite a while (I kind of gave up on Linux mixers a while back and have been focusing on developing a usable software mixer of my own instead). In your situation, it doesn’t seem possible to not use the Java Sound Audio Engine, if there are no usable alternative mixers available. I think the first question to try and answer is why it is missing in the first place. I’ll look into this to see if Java Sound Audio Engine is available on my netbook with the latest version of Oracle Java or not (I’m using OpenJDK at the moment).

Are those mixers recent additions? I don’t recall those being available in the past (it has been a while since I worked on this though). I guess even if they are a recent addition, you can’t really count on your target audience to have them depending on what version of OpenJDK they’re running.

Java Sound Audio Engine is not available on my netbook either for the recent version of Oracle Java. That’s really odd - I’m almost positive that it was available on previous versions. I wonder if they officially did away with it or something? In my case, I do have two mixers available with 32 lines, plus two with zero lines.

Socob, could you link with the following version of the plug-in instead (it prints a little more information to the console than the previous version):
LibraryJavaSound plug-in

The test should be simple to run - just instantiate the SoundSystem and grab what gets printed to the console. Alternately, you can run the following applet and grab the console output (it’ll be a bit messier, but should have all the same info in there as well):
Bullet / Target Collision Applet

gouessej, could you also run either of the above and post the output? Looking at the code, you may have multiple lines available on your mixer like I do, regardless of the fact that only the first sound played correctly. I’ll have to verify that with the output, though. If so, then my upcoming release of the LibraryJavaSound plug-in should fix your problem. Socob’s problem is going to be more difficult to solve.

Mageia Linux 1, 32 bits AMD Sempron, Oracle JVM 1.6 update 26:

[quote]Starting up SoundSystem…
Initializing Java Sound
(The Java Sound API. For more information, see http://java.sun.com/products/java-media/sound/)
Mixer ‘Java Sound Audio Engine’
Exists: true
Minimum Sample Rate: 4000
Acceptable: true
Maximum Sample Rate: 48000
Acceptable: true
Maximum Lines: 32
Acceptable: true
Gain Control: true
Pan Control: true
Sample Rate Control: true
Total Rank: 14
JavaSound initialized.

network: Entrée de cache introuvable [URL : http://www.paulscode.com/source/BulletTargetCollision/, version : null]
network: Entrée de cache introuvable [URL : http://www.paulscode.com/source/BulletTargetCollision/org/lwjgl/opengl/JOGLPresent.class, version : null]
network: Connexion de http://www.paulscode.com/source/BulletTargetCollision/org/lwjgl/opengl/JOGLPresent.class avec proxy=DIRECT
Java version is: 1.6.0_26
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
Adding Lightsource: 0
basic: Applet initialized
basic: Récepteur de progression supprimé : sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@173ec72
basic: Applet made visible
basic: Starting applet
basic: completed perf rollup
basic: Applet started
basic: Told clients applet is started
Software renderer disposed
[/quote]
I will test it on another machine with OpenJDK 1.6 and Intel 64 bits.

That isn’t the system that had the problem with playing only the first sound one time, is it? It seems to have the Java Sound Audio Engine, which doesn’t have that problem.

BTW, Socob, sorry to hyjack your thread again, but I figured this was a good place to discuss this issue as well as yours, since they are both related to mixers on Linux.

@paulscode:

[quote=“paulscode,post:32,topic:37148”]
I have no idea how recent they are, but a link I’ve brought up earlier in this thread suggests that they’re at least fairly recent. Even if it is a hindrance, I think it’s fair to tell users to update their JRE version. At least it’s better than having to tell them to specifically use either an Oracle JRE or OpenJDK, which is what I’ve been dealing with so far.

Anyway, thank you for posting a test. I’m using Linux Mint 11 32bit with the Oracle JVM 1.6 update 26. First, I tried the Bullet/Target Collision applet with nothing else running (i.e. no Flash or anything) and got sound:

Starting up SoundSystem...
Initializing Java Sound
    (The Java Sound API.  For more information, see http://java.sun.com/products/java-media/sound/)
Mixer 'NVidia [plughw:0,0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'NVidia [plughw:0,1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'NVidia [plughw:0,2]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Generic [plughw:1,3]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'Port NVidia [hw:0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Port Generic [hw:1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Attempting to use Mixer 'NVidia [plughw:0,0]'
JavaSound initialized.

Java version is: 1.6.0_26
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
Adding Lightsource: 0
Software renderer disposed

Next, I tried the same with a Flash video running at the same time; no sound here:

Starting up SoundSystem...
Initializing Java Sound
    (The Java Sound API.  For more information, see http://java.sun.com/products/java-media/sound/)
Mixer 'NVidia [plughw:0,0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'NVidia [plughw:0,1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'NVidia [plughw:0,2]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Generic [plughw:1,3]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'Port NVidia [hw:0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Port Generic [hw:1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Attempting to use Mixer 'NVidia [plughw:0,1]'
JavaSound initialized.

Java version is: 1.6.0_26
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
Adding Lightsource: 0
Software renderer disposed

Note that the “NVidia” mixers seem to be related to my soundcard (it’s an onboard soundcard). “NVidia [plughw:0,0]” is able to play sound from my speakers, but as you can see, if sound is already running, the maxmimum number of lines is zero. I have no idea what “NVidia [plughw:0,1]” is, but I can’t hear anything when that’s used.

The mixer called “Generic” is the HDMI port of my graphics card, so I wouldn’t want to use that.

Also, I seem to have the same problem that I can only hear the first sound (even in the first test). After I shoot the second laser in the applet, I get this on every shot:

Error in class 'ChannelJava Sound'
    Unable to attach buffer to clip in method 'attachBuffer'
    ERROR MESSAGE:
        line with format PCM_UNSIGNED 11025.0 Hz, 8 bit, stereo, 2 bytes/frame,  not supported.
    STACK TRACE:
        com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:494)
        com.sun.media.sound.DirectAudioDevice$DirectClip.implOpen(DirectAudioDevice.java:1280)
        com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:107)
        com.sun.media.sound.DirectAudioDevice$DirectClip.open(DirectAudioDevice.java:1061)
        com.sun.media.sound.DirectAudioDevice$DirectClip.open(DirectAudioDevice.java:1028)
        paulscode.sound.libraries.ChannelJavaSound.attachBuffer(ChannelJavaSound.java:278)
        paulscode.sound.libraries.SourceJavaSound.play(SourceJavaSound.java:311)
        paulscode.sound.Library.play(Library.java:706)
        paulscode.sound.Library.play(Library.java:675)
        paulscode.sound.SoundSystem.CommandPlay(SoundSystem.java:2076)
        paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2599)
        paulscode.sound.CommandThread.run(CommandThread.java:121)

This error applies to both tests.

For comparison, on OpenJDK (version 1.6 update 22), everything seems to be working fine. Here is the console output:

Starting up SoundSystem...
Initializing Java Sound
    (The Java Sound API.  For more information, see http://java.sun.com/products/java-media/sound/)
Mixer 'default [default]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'NVidia [plughw:0,0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'NVidia [plughw:0,1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'NVidia [plughw:0,2]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Generic [plughw:1,3]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 32
        Acceptable: true
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 9
Mixer 'Port NVidia [hw:0]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Mixer 'Port Generic [hw:1]'
    Exists: true
    Minimum Sample Rate: 4000
        Acceptable: true
    Maximum Sample Rate: 48000
        Acceptable: true
    Maximum Lines: 0
        Acceptable: false
    Gain Control: false
    Pan Control: false
    Sample Rate Control: false
    Total Rank: 0
Attempting to use Mixer 'default [default]'
JavaSound initialized.

Java version is: 1.6.0_22
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
Adding Lightsource: 0

Thanks for the detailed explanations. Is there only one program (you mentioned Flash video) that causes the problem, or is it caused by anything that plays sound? Once the offending program(s) are shut down, does sound start working again, or do you have to reboot to get sound back?

Also, for clarification, when NVidia [plughw:0,1] was used, you didn’t even hear the first sound play, correct?

About the first sound playing and not the subsequent sounds - interestingly, it used to be reversed (this used to affect OpenJDK sometimes but not Sun Java - although I think that was because Sun Java used to reliably have the Java Sound Audio Engine… doesn’t seem to be the case any more). I’m getting the same thing on my netbook with the recent version of Oracle Java. What causes this is that you have a maximum number of lines, after which no more can be created. That’s all well and good, but for some reason, some of the time (depending on Java version and hardware apparently), even if you shut down and discard one of the lines, you still can not create any more (throws an error on dataLine.open). Because of the way the SoundSystem currently works, each new source you create with a new audio format must shut down one of the lines to create a new one (because I could not find any way with the API to change the audio format of an existing line - point me in the right direction if anyone knows of a way, please). So depending on how many lines were created in the ranking system, you end up with a limited number of lines left to play sounds on (resulting in the behavior of the first sound playing, then no subsequent sounds). I’m improving the way the line management and ranking works, and as long as you use all files of the same audio format, that problem should be gone from the next release of LibraryJavaSound.

All that being said, this will only help you if Flash, etc. are not playing. I’ll have to think about this one some more…

[quote=“paulscode,post:37,topic:37148”]
As far as I can tell, everything that plays sound causes the problem. I tried a few more programs, and so far, I haven’t found anything that didn’t cause it. Sound does start working again once I close all of the offending programs, so I don’t have to reboot.

Yes.

[quote=“paulscode,post:37,topic:37148”]
I don’t know how much (if any) of this changed with Java 1.7, but so far, it does look like JavaSound really is impossible to use reliably on Linux, especially now that the “Java Sound Audio Engine” seems to be gone on some machines for some reason. I guess the only way to solve this at all would be to open a bug report on Java development or something (again, as long as this still happens with Java 1.7)? I really don’t see any other way as long as you can’t even get the most basic sound output.

In fact, it is. I use 2 JVMs on this machine (at home), it works fine with Oracle JVM as you see but not with OpenJDK.

I cannot use applets on the 64 bits machine, do you have a Web Start version?

I have already submitted several reports including one about sound on Linux and it might be never fixed. I’m sorry to say that but I’m forced to switch to OpenAL and I advise you to do so.

Rgr, problem with OpenJDK, not with Oracle JVM (that was historically the case, although now I’m forced to conclude that at some point in a recent version, Oracle has shot themselves in the foot by making their closed-source product less compatible on Linux by removing the Java Sound Audio Engine and not providing an alternative software mixer).

[quote=“gouessej,post:39,topic:37148”]
Not off hand. I’ll have a better test program to run for the next round.

That’s kind of where I’m at in the thought process as well. If you had even a single line that you could reliably play on, then mixing would be possible, but without that I really can’t think of what alternative there is. Fingers crossed they fix at least one of those issues in the next release of Java.

[quote=“gouessej,post:39,topic:37148”]
This really vexes me, because I write applets almost exclusively. I know from experience that a lot of people simply will not accept a security exception on a web page (especially when the warning recommends that they don’t). A pure-Java option for 3D audio is absolutely critical.

I suppose one could just warn the user that if they are experiencing issues with no audio, to ensure that no other program is playing audio while the application is starting up. That would give the sound system a chance to grab an available line (and not ever close it until the application shuts down). Only problem with that idea is that although the application would now have sound, nothing else would (so the user would be out of luck if they wanted to listen to mp3’s or hear IM warning sounds for example, while they were running it)