[vlc-devel] [PATCH] EqualizerBar: Change unit prefix threshold due to rounding scheme

Ronald Wright logiconcepts819 at gmail.com
Sun Aug 18 20:13:44 CEST 2013


The rounding scheme used in the EqualizerBar introduced a very subtle issue.
Frequencies close to 1000 Hz (if we ever have any) may be rendered as "1000 Hz"
rather than "1 kHz". For example, take 999.8 Hz. This value rounds up to 1000
Hz, but the value used for comparing against the threshold value of 1000 Hz is
still 999.8 Hz. Since 999.8 Hz is less than 1000 Hz, the rounded value is
rendered as "1000 Hz" rather than "1 kHz". To compensate for this issue, the
threshold must be 999.5 Hz rather than 1000 Hz.
---
 vlc-android/src/org/videolan/vlc/widget/EqualizerBar.java |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/widget/EqualizerBar.java b/vlc-android/src/org/videolan/vlc/widget/EqualizerBar.java
index e861646..444d4e9 100644
--- a/vlc-android/src/org/videolan/vlc/widget/EqualizerBar.java
+++ b/vlc-android/src/org/videolan/vlc/widget/EqualizerBar.java
@@ -59,7 +59,7 @@ public class EqualizerBar extends LinearLayout {
         mSeek.setProgress(RANGE);
         mSeek.setOnSeekBarChangeListener(mSeekListener);
         mBand = (TextView) findViewById(R.id.equalizer_band);
-        mBand.setText(band < 1000.0f
+        mBand.setText(band < 999.5f
                 ? (int) (band + 0.5f) + " Hz"
                 : (int) (band / 1000.0f + 0.5f) + " kHz");
         mValue = (TextView) findViewById(R.id.equalizer_value);
-- 
1.7.10.4




More information about the vlc-devel mailing list