summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2012-02-24 14:21:16 -0800
committerMike Lockwood <lockwood@google.com>2012-03-22 15:09:12 -0700
commit24b082f87e96c00d5c17d60c735423900be40e70 (patch)
treea2e26d005cceb3a1f584826934f78f09faf42b0e /media
parentc1c0ced6698978cb4226148a422503fdac6b59b5 (diff)
downloadframeworks_base-24b082f87e96c00d5c17d60c735423900be40e70.zip
frameworks_base-24b082f87e96c00d5c17d60c735423900be40e70.tar.gz
frameworks_base-24b082f87e96c00d5c17d60c735423900be40e70.tar.bz2
Fix Audio ramping code
The audio ramping was being ignored and we were always adjusting by the same amount. Change-Id: Id4a6587fd488132816ae26776c0f798782470b1d
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index aa60d0a..60b9ac0 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -623,23 +623,32 @@ public class AudioService extends IAudioService.Stub {
ensureValidDirection(direction);
int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME);
int delta = 0;
- for (int i = 0; i < mMasterVolumeRamp.length; i += 2) {
- int testVolume = mMasterVolumeRamp[i];
- int testDelta = mMasterVolumeRamp[i + 1];
- if (direction == AudioManager.ADJUST_RAISE) {
- if (volume >= testVolume) {
- delta = testDelta;
- } else {
+
+ if (direction == AudioManager.ADJUST_RAISE) {
+ // This is the default value if we make it to the end
+ delta = mMasterVolumeRamp[1];
+ // If we're raising the volume move down the ramp array until we
+ // find the volume we're above and use that groups delta.
+ for (int i = mMasterVolumeRamp.length - 1; i > 1; i -= 2) {
+ if (volume >= mMasterVolumeRamp[i - 1]) {
+ delta = mMasterVolumeRamp[i];
break;
}
- } else if (direction == AudioManager.ADJUST_LOWER) {
- if (volume - testDelta >= testVolume) {
- delta = -testDelta;
- } else {
+ }
+ } else if (direction == AudioManager.ADJUST_LOWER){
+ int length = mMasterVolumeRamp.length;
+ // This is the default value if we make it to the end
+ delta = -mMasterVolumeRamp[length - 1];
+ // If we're lowering the volume move up the ramp array until we
+ // find the volume we're below and use the group below it's delta
+ for (int i = 2; i < length; i += 2) {
+ if (volume <= mMasterVolumeRamp[i]) {
+ delta = -mMasterVolumeRamp[i - 1];
break;
}
}
}
+
// Log.d(TAG, "adjustMasterVolume volume: " + volume + " delta: " + delta + " direction: " + direction);
setMasterVolume(volume + delta, flags);
}