changeset 2567:748c609a6a14

R902: PulseAudioClip getMicrosecondsLength() returns length in milliseconds, not microseconds Define a (correct) constant for converting from seconds to microsecond and use it everywhere. 2012-06-28 Omair Majid <omajid@redhat.com> * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java (getMicrosecondLength, getMicrosecondPosition) (setMicrosecondPosition): Use correct factor to convert seconds to microseconds. * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java (getMicrosecondPosition): Likewise. * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java: Define SECONDS_TO_MICROSECONDS.
author Omair Majid <omajid@redhat.com>
date Thu, 28 Jun 2012 19:54:43 -0400
parents dfdf72956eee
children 7a7d8d40ae38
files ChangeLog NEWS pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
diffstat 5 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jun 28 19:45:23 2012 -0400
+++ b/ChangeLog	Thu Jun 28 19:54:43 2012 -0400
@@ -1,3 +1,14 @@
+2012-06-28  Omair Majid  <omajid@redhat.com>
+
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java
+	(getMicrosecondLength, getMicrosecondPosition)
+	(setMicrosecondPosition): Use correct factor to convert seconds to
+	microseconds.
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
+	(getMicrosecondPosition): Likewise.
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java:
+	Define SECONDS_TO_MICROSECONDS.
+
 2012-06-28  Omair Majid  <omajid@redhat.com>
 
 	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
--- a/NEWS	Thu Jun 28 19:45:23 2012 -0400
+++ b/NEWS	Thu Jun 28 19:54:43 2012 -0400
@@ -13,6 +13,7 @@
 New in release 2.3 (2012-XX-XX):
 
 * Bug fixes
+  - PR902: PulseAudioClip getMicrosecondsLength() returns length in milliseconds, not microseconds
   - PR986: IcedTea7 fails to build with IcedTea6 CACAO due to low max heap size
   - PR1050: Stream objects not garbage collected
 
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Thu Jun 28 19:45:23 2012 -0400
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Thu Jun 28 19:54:43 2012 -0400
@@ -343,7 +343,7 @@
             return AudioSystem.NOT_SPECIFIED;
         }
         synchronized (clipLock) {
-            return (long) (frameCount / currentFormat.getFrameRate() * 1000);
+            return (long) (frameCount / currentFormat.getFrameRate() * SECONDS_TO_MICROSECONDS);
         }
     }
 
@@ -354,7 +354,7 @@
         }
 
         synchronized (clipLock) {
-            return (long) (framesSinceOpen / currentFormat.getFrameRate() * 1000);
+            return (long) (framesSinceOpen / currentFormat.getFrameRate() * SECONDS_TO_MICROSECONDS);
         }
     }
 
@@ -503,7 +503,7 @@
             throw new IllegalStateException("Line not open");
         }
 
-        float frameIndex = microseconds * currentFormat.getFrameRate() / 1000;
+        float frameIndex = microseconds * currentFormat.getFrameRate() / SECONDS_TO_MICROSECONDS;
 
         /* make frameIndex positive */
         while (frameIndex < 0) {
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java	Thu Jun 28 19:45:23 2012 -0400
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java	Thu Jun 28 19:54:43 2012 -0400
@@ -42,6 +42,8 @@
  */
 interface PulseAudioPlaybackLine {
 
+    static final int SECONDS_TO_MICROSECONDS = 1000000;
+
     /**
      * Set the volume of the Line (ie, sink input, source, or sink)
      * 
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Thu Jun 28 19:45:23 2012 -0400
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Thu Jun 28 19:54:43 2012 -0400
@@ -259,7 +259,7 @@
 
         float frameRate = currentFormat.getFrameRate();
         float time = framesSinceOpen / frameRate; // seconds
-        long microseconds = (long) (time * 1000);
+        long microseconds = (long) (time * SECONDS_TO_MICROSECONDS);
         return microseconds;
     }