Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5070730
Votes 34
Synopsis REGRESSION: play method audioclip
Category java:classes_sound
Reported Against tiger-beta2
Release Fixed 5.0u2(b07)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6251460 , 6359944 , 4365713 , 4435394 , 4735740 , 6186076 , 6233477
Submit Date 01-JUL-2004
Description


FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Windows xp

A DESCRIPTION OF THE PROBLEM :
audioclip play method does not work. but loop method does.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
play any .au file using
audioClip ac;
ac = JApplet.newAudioClip(url of au file));
ac.play() // does not work;
ac.loop() works;

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
sound should play
ACTUAL -
sound does not play

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.applet.*;
import java.net.*;

public class Bug{
    public static void main(String[] args) {

        AudioClip ac=Applet.newAudioClip(Bug.class.getResource("yes.au"));
        ac.play();
        // ac.loop();
    }
}

This I can compile.
I need a "0.au" file in the same directory as the Bug class file.

While running

C:\j2sdk1.4.2_03\jre\bin\java.exe Bug
plays the sound

"C:\Program Files\Java\jre1.5.0\bin\java.exe" Bug
does not play the sound
---------- END SOURCE ----------

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 281874) 
======================================================================
  xxxxx@xxxxx   2004-07- customer 
Work Around
N/A
Evaluation
Don't see the test.
  xxxxx@xxxxx   2004-07-01

java.applet.AppletAudioClip which is used in the test is a simple wrapper for 
com.sun.media.sound.JavaSoundAudioClip, here is rewritten test which use this
class directly and demostrate the problem.
--- Bug.java ---
import java.applet.*;
import java.net.*;
import com.sun.media.sound.JavaSoundAudioClip;

public class Bug{
    public static void main(String[] args) {
        try {
            JavaSoundAudioClip ac = new JavaSoundAudioClip(Bug.class.getResource("yes.au").openStream());
            ac.play();
        } catch (Exception e3) {
            System.err.println("Failed to construct the AudioClip: " + e3);
        }
    }
}
--- end of Bug.java ---

Thus this is java sound's problem, not applet's one.
  xxxxx@xxxxx   2004-09-17

This might be either java sound or io problem, reassigning to javasound for further investigation.
  xxxxx@xxxxx   2004-09-17
  xxxxx@xxxxx   2005-2-10 01:15:36 GMT

The simplified testcase differs from the incidents on the
JavaMedia forum.  It works on 1.4.2 because of a bug that
does not terminate the JVM when the program ends, see CR
4735740. If delay is added to the testcase it works on 1.5.0.

Most of the incidents on the forum indicate short audio clips
are not played while the program / applet continues. A boundary
condition exists in PLATFORM_API_WinOS_DirectSound.cpp in
src/windows/native/com/sun/media/sound/engine/ that is
frequently hit on very small files. Silence is played
instead of the audio clip.

  xxxxx@xxxxx   2005-2-18 03:12:32 GMT

Trying to verify the fix on 1.5.0_02 B07 and B08 but the following code will not play the complete clip and the JVM will exit while playing it.

AudioClip ac = Applet.newAudioClip(Bug.class.getResource("spacemusic.au");
//The following play() will not play the whole audio clip unless Thread.sleep(delay) is introduced after it.
ac.play();
//And JVM will exit before loop() method to complete the audio clip unless Thread.sleep(delay) after it.
ac.loop();
  xxxxx@xxxxx   2005-2-28 22:36:44 GMT

As mentioned above, simplified testcase differs from the incidents
on the JavaMedia forum.  It ONLY works on 1.4.2 because of a bug
that does not terminate the JVM when the program ends, see CR
4735740.

AudioClip.play() is asynchronous; it starts playing audio, it
returns as soon as the clip is started, it does not delay the
current thread to the end of the clip.

Since the fix fo CR 4735740 is in 1.5.0, the delay is needed
in the testcase following ac.play().

  xxxxx@xxxxx   2005-3-01 01:09:18 GMT

Users may run into problem when they cannot query the length of the audio clip at runtime, hence, do not know how long the delay is needed for the sleep.
  xxxxx@xxxxx   2005-03-01 18:26:56 GMT

AudioClip is not intended for the type of program that needs
to know how long the clip is in order to wait for it. If it
is absolutely necessary to wait for a clip to complete, the
addLineListener function can be used to associate an event
listener that can be executed when the clip completes playing.

The intent of AudioClip is to allow a programmer to trigger
a sound when an event occurs without having to manage play
of the clip. For instance in a game when an object collides
with a wall the programmer may want to start a collision
sound, change the object's trajectory, possibly indicate
damage to the object or the wall and go back to the main
loop of the game. In another case, say to simulate a car
alarm, the programmer may want to trigger a looping clip
until an event occurs that would clear the alarm; at that
time the programmer would invoke stop() on the clip.
an.
  xxxxx@xxxxx   2005-03-01 19:11:35 GMT
Comments
  
  Include a link with my name & email   

Submitted On 11-OCT-2004
wmjoers
What is happening to this bug? Will there be a patch soon? 


Submitted On 12-OCT-2004
Bombadil9
As said, it's not just applets, it's also normal applications. It's not just clips, it's also with MIDI, short WAVs, and so on.
There are some serious bugs in Javasound 1.50 final.

Just load the official Javasound Demo: url=http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/
It does produce these results on a Win2000 box (and on other people's PCs):
0. 1-welcome.wav : works
1. 22-new.aif : works
2. sfx-medley.rmf : [i]silence[/i]
3. spacemusic.au : works
4. trippygaia1.mid : [i]silence[/i]


Submitted On 12-OCT-2004
nongnong
why release java 1.5 if the bug is still not fixed for beta?


Submitted On 12-OCT-2004
Bombadil9
It's also to be reported against Java 1.50 final, not just beta.

This bug screws many sounds in games etc. :-(


Submitted On 14-OCT-2004
wmjoers
PLEASE! Give us some information on WHEN we can use 1.5 for audio  play back.


Submitted On 04-NOV-2004
robtaft
I'm assuming this bug is what is causing Pogo.com to not work properly with 1.5?  Is it possible to verify this?


Submitted On 04-NOV-2004
Calibrus
Yep.  In fact every game applet I've tried, regardless of web site its on, has sound problems when using 1.5.  Some sounds play while others only make a brief click or no sound at all.


Submitted On 20-NOV-2004
Ambroise3
should anyone at sun have a look to this bug. It is really important !
Regards.


Submitted On 04-JAN-2005
_mrjbq7_
A workaround that appears to work is to locate the software mixer:

private static Mixer mixer;

    static {
        Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        for (int i = 0; i < mixers.length; i++) {
            if ("Java Sound Audio Engine".equals(mixers[i].getName())) {
                mixer = AudioSystem.getMixer(mixers[i]);
            }
        }
    }

And then create the clip from the mixer (if available):

    if (mixer != null) {
        soundClip = (Clip) mixer.getLine(info);
    } else {
        soundClip = (Clip) AudioSystem.getLine(info);
     }


Submitted On 13-JAN-2005
robtaft
It's not an issue of a work around.  It is an issue of backwards compatability with Java 1.1


Submitted On 18-JAN-2005
patrickmallette
Any sound less than 1 second long is affected. 


Submitted On 12-APR-2005
PSellhorst
Not fixed. See bug 6251460.



PLEASE NOTE: JDK6 is formerly known as Project Mustang