Skip to main content

Clip timing issue

1 reply [Last post]
mortennobel
Offline
Joined: 2004-11-03

I have found another minor issue (With the current Subversion version).
When I add a Trigger with autoreverse, there seems to be a bug during the autoreverse of the Clip. The seems like a buggy clip is started during the autoreverse.

public class AnimationTest extends JApplet {
public void init(){
Color bgColorAlt = Color.pink;
Container contentPane = getContentPane();
Clip clip = Clip.create(5000,contentPane,"background",contentPane.getBackground(),bgColorAlt);
clip.addTarget(new TimingTargetAdapter(){
public void timingEvent(float fraction) {
System.out.println("fraction = " + fraction);
}
});
clip.setInterpolator(Interpolators.getLinearInstance());
contentPane.addMouseListener(new MouseTrigger(clip, MouseTriggerEvent.PRESS,true));
}
}

The output is:
fraction = 0.0128
fraction = 0.016
fraction = 0.016
fraction = 0.016
fraction = 0.016
fraction = 0.016
fraction = 0.019
[...]

fraction = 0.368
fraction = 0.368
fraction = 0.629
fraction = 0.998
fraction = 0.62880003
fraction = 0.9978
[...]
fraction = 0.3706
fraction = 0.0013999939
fraction = 0.3704
fraction = 0.0

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jim Graham

This looks like a bad interaction between the auto-reverse mechanism of
the MouseTriggers and the asynchronous nature of stopping a Clip.

The way the auto-reverse stops and then immediately restarts the Clip
causes a race condition that 999/1000 times will leave both run queue
entries (the original forward entry and the new reverse entry) active
and fighting each other.

I'll have to rethink the way we remove stopped clips from the run queue...

...jim

scenario@javadesktop.org wrote:
> I have found another minor issue (With the current Subversion version).
> When I add a Trigger with autoreverse, there seems to be a bug during the autoreverse of the Clip. The seems like a buggy clip is started during the autoreverse.
>
>
> public class AnimationTest extends JApplet {
> public void init(){
> Color bgColorAlt = Color.pink;
> Container contentPane = getContentPane();
> Clip clip = Clip.create(5000,contentPane,"background",contentPane.getBackground(),bgColorAlt);
> clip.addTarget(new TimingTargetAdapter(){
> public void timingEvent(float fraction) {
> System.out.println("fraction = " + fraction);
> }
> });
> clip.setInterpolator(Interpolators.getLinearInstance());
> contentPane.addMouseListener(new MouseTrigger(clip, MouseTriggerEvent.PRESS,true));
> }
> }
>
> The output is:
> fraction = 0.0128
> fraction = 0.016
> fraction = 0.016
> fraction = 0.016
> fraction = 0.016
> fraction = 0.016
> fraction = 0.019
> [...]
>
> fraction = 0.368
> fraction = 0.368
> [b]fraction = 0.629[/b]
> [b]fraction = 0.998[/b]
> [b]fraction = 0.62880003[/b]
> [b]fraction = 0.9978[/b]
> [...]
> [b]fraction = 0.3706[/b]
> fraction = 0.0013999939
> [b]fraction = 0.3704[/b]
> fraction = 0.0
> [Message sent by forum member 'mortennobel' (mortennobel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=254634
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
> For additional commands, e-mail: dev-help@scenegraph.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net