Add volume range translation 57/54257/3
authorjinwoo.shin <jw0227.shin@samsung.com>
Mon, 14 Dec 2015 10:15:19 +0000 (19:15 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Tue, 15 Dec 2015 04:48:02 +0000 (13:48 +0900)
Change-Id: Ibf32f03ce41c7b134e6873f76c0bd96d3e4676c3
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
include/volume.h
src/volume.c

index 1ba1ed8..05b3c21 100644 (file)
@@ -21,7 +21,7 @@
 
 #define MUTE_VALUE 0
 #define VOLUME_MIN 0
-#define VOLUME_MAX 15
+#define VOLUME_MAX 50
 #define VOLUME_DEFAULT 10
 
 void volume_init(void);
index c2551ce..e804beb 100644 (file)
@@ -26,13 +26,8 @@ static int volume;
 
 void volume_init(void)
 {
-       int r;
-
-       r = volume_get_volume();
-       if (r < 0)
-               volume = VOLUME_DEFAULT;
-       else
-               volume = r;
+       volume = VOLUME_DEFAULT;
+       sound_manager_get_master_volume(&volume);
 
        mute = false;
 }
@@ -54,6 +49,16 @@ bool volume_is_mute(void)
        return mute;
 }
 
+static int _volume_get_max_volume(void)
+{
+       int vol;
+
+       vol = VOLUME_MAX;
+       sound_manager_get_max_master_volume(&vol);
+
+       return vol;
+}
+
 int volume_set_volume(int vol)
 {
        int r;
@@ -64,6 +69,8 @@ int volume_set_volume(int vol)
                return -1;
        }
 
+       vol = (vol * _volume_get_max_volume()) / VOLUME_MAX;
+
        r = sound_manager_set_master_volume(vol);
        if (r < 0) {
                _ERR("failed to set volume");
@@ -79,12 +86,15 @@ int volume_get_volume(void)
 {
        int vol, r;
 
-       if (volume_is_mute())
-               return volume;
+       if (volume_is_mute()) {
+               vol = volume;
+       } else {
+               r = sound_manager_get_master_volume(&vol);
+               if (r < 0)
+                       return -1;
+       }
 
-       r = sound_manager_get_master_volume(&vol);
-       if (r < 0)
-               return -1;
+       vol = (vol * VOLUME_MAX) / _volume_get_max_volume();
 
        return vol;
 }