You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2010/01/28 23:32:27 UTC

DO NOT REPLY [Bug 48637] New: sound task either does nothing or endlessly loops sound.

https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

           Summary: sound task either does nothing or endlessly loops
                    sound.
           Product: Ant
           Version: 1.8.0RC1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: edbrannin@gmail.com


This bug exists in 1.7.0 and 1.8.0RC1, and has existed since at least November
2008: http://bit.ly/d8ydaU

Using only the "source" attribute on <sound>'s <success> and <fail> elements,
the sound task does nothing.

As the email thread above says, using the duration task causes the sound to
loop forever.

I'm attaching a proof-of-concept, including some sounds and a tiny Java class
that proves javax.sound works.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

--- Comment #1 from Ed Brannin <ed...@gmail.com> 2010-01-28 14:34:42 UTC ---
Created an attachment (id=24902)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24902)
Proof-of-problem project.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

--- Comment #2 from Ed Brannin <ed...@gmail.com> 2010-01-29 07:44:31 UTC ---
Created an attachment (id=24905)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24905)
Patch against 1.8.0RC1 to fix both issues (and fix some comment spelling)

I downloaded the 1.8.0RC1 source distribution and fixed both issues this
morning.

===

In org.apache.tools.ant.taskdefs.optional.sound.AntSoundPlayer.playClip(Clip,
int): 
There was a race condition between clip.loop() and clip.isRunning() where the
system could exit before the clip started.

I don't like how this takes one busy-wait and turns it into two busy-waits, and
am going to replace them with a do/try/sleep loop in a minute.  I'm uploading
this patch now in case you prefer this version.

In org.apache.tools.ant.taskdefs.optional.sound.AntSoundPlayer.playClip(Clip,
long):
clip.loop(Clip.LOOP_CONTINUOUSLY) and the ensuing Thread.sleep(duration) worked
fine, but no one ever called clip.stop() at the end.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] [PATCH] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
            Version|1.8.0RC1                    |1.7.1
         Resolution|                            |FIXED
   Target Milestone|---                         |1.8.0

--- Comment #7 from Stefan Bodewig <bo...@apache.org> 2010-01-29 08:26:43 UTC ---
svn revision 904546

Thanks!

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] [PATCH] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

--- Comment #6 from Stefan Bodewig <bo...@apache.org> 2010-01-29 08:23:16 UTC ---
Actually I started looking into the issue just before you attached your first
patch.  I'm about to commit a modified version of your second patch in a few
minutes (by sheer luck I ran into a situation where timeLeft turned negative in
my very first loop test).

The race condition never occurred with Java 1.4 for me, but I always heard the
results you described when using 1.6.  The patched version works on either Java
version.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] [PATCH] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

Ed Brannin <ed...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|sound task either does      |[PATCH] sound task either
                   |nothing or endlessly loops  |does nothing or endlessly
                   |sound.                      |loops sound.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

Ed Brannin <ed...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24905|0                           |1
        is obsolete|                            |

--- Comment #3 from Ed Brannin <ed...@gmail.com> 2010-01-29 08:02:54 UTC ---
Created an attachment (id=24906)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24906)
Patch against 1.8.0RC1 to fix both issues (and fix some comment spelling) -
PLUS no more busy-waits.

The original code (and my original fix) would busy-wait for the sound to finish
playing.  On my system, the "empty" loops (now with "waits += 1") ran about 940
million times.

This patch reduces the wait-count to around 2-20.  Higher wait-counts are from 
the lag between clip.getMicrosecondLength() == clip.getMicrosecondPosition()
and clip.isRunning() going back to false.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

Ed Brannin <ed...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24902|0                           |1
        is obsolete|                            |

--- Comment #4 from Ed Brannin <ed...@gmail.com> 2010-01-29 08:12:16 UTC ---
Created an attachment (id=24907)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24907)
A test class that explains and demonstrates both issues (uses Windows sounds by
default).

Here's a test class that reproduces the issue, directly using the
AntSoundPlayer class.  It uses c:\windows\media\tada.wav by default, so you'll
have to change the path if you're on OS X or Linux.

I'm obsoleting the attachment that reproduced the issues via an ant buildfile.

I didn't write it as a JUnit test because it requires some manual input and
verification.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 48637] [PATCH] sound task either does nothing or endlessly loops sound.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48637

Ed Brannin <ed...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24907|application/octet-stream    |text/x-java-source
          mime type|                            |

--- Comment #5 from Ed Brannin <ed...@gmail.com> 2010-01-29 08:16:53 UTC ---
(From update of attachment 24907)
updating the MIIME type to text/x-java-source

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.