summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hanner <christian3.hanner@sonymobile.com>2014-03-31 11:02:49 +0200
committerSteve Kondik <shade@chemlab.org>2014-06-08 02:54:03 +0000
commitbbf48580cf6b34d438c788f9b4badaeb419fd1c4 (patch)
treef10d4f9cace37dd8ab1346b0cf2fd24ac56d073c
parentfcd16d32cb7c3c14da7b54722ce3456840cb9289 (diff)
downloadandroid_packages_apps_Bluetooth-bbf48580cf6b34d438c788f9b4badaeb419fd1c4.tar.gz
android_packages_apps_Bluetooth-bbf48580cf6b34d438c788f9b4badaeb419fd1c4.tar.bz2
android_packages_apps_Bluetooth-bbf48580cf6b34d438c788f9b4badaeb419fd1c4.zip
Use round() instead of ceil() in calculation of a2dp vol slider position
The avrcp MESSAGE_VOLUME_CHANGED requests volumes in the range 0-127. In convertToAudioStreamVolume() this value is scaled to a (typically much smaller, e.g. 0-15) integer value representing the volume slider step to be presented in the UI. Depending on the resolution in the volume requests from the a2dp device and the resolution of the UI volume slider, some of the requested volumes might be mapped onto the same UI slider positions. If ceil() is exchanged for round() in convertToAudioStreamVolume() the problem with double mapped volumes vanishes in most realistic cases. Change-Id: I89d9ac4b8c330fd4fd2a02984bd628961f2cb035
-rw-r--r--src/com/android/bluetooth/a2dp/Avrcp.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/a2dp/Avrcp.java b/src/com/android/bluetooth/a2dp/Avrcp.java
index 9bbafcc2f..6ad7d28b9 100644
--- a/src/com/android/bluetooth/a2dp/Avrcp.java
+++ b/src/com/android/bluetooth/a2dp/Avrcp.java
@@ -1473,7 +1473,7 @@ final class Avrcp {
private int convertToAudioStreamVolume(int volume) {
// Rescale volume to match AudioSystem's volume
- return (int) Math.ceil((double) volume*mAudioStreamMax/AVRCP_MAX_VOL);
+ return (int) Math.round((double) volume*mAudioStreamMax/AVRCP_MAX_VOL);
}
private int convertToAvrcpVolume(int volume) {