Add sound manager integration 65/45265/1
authorjinwoo.shin <jw0227.shin@samsung.com>
Tue, 4 Aug 2015 08:16:25 +0000 (17:16 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Tue, 4 Aug 2015 08:16:25 +0000 (17:16 +0900)
Change-Id: I83209cb1a1fa1d01f25625d3d83dc108b6b8343c
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
CMakeLists.txt
include/volume.h
packaging/org.tizen.volume.spec
src/main.c
src/volume.c

index f06b83d..1931d97 100644 (file)
@@ -57,7 +57,8 @@ pkg_check_modules(PKGS REQUIRED
                ecore
                edje
                app-utils
-               capi-appfw-application)
+               capi-appfw-application
+               capi-media-sound-manager)
 
 FOREACH(flag ${PKGS_CFLAGS})
        SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}")
index 00e3aff..1ba1ed8 100644 (file)
 
 #define MUTE_VALUE 0
 #define VOLUME_MIN 0
-#define VOLUME_MAX 50
+#define VOLUME_MAX 15
+#define VOLUME_DEFAULT 10
 
+void volume_init(void);
 int volume_set_mute(bool is_mute);
 bool volume_is_mute(void);
 int volume_set_volume(int level);
index 04477ca..23709fc 100644 (file)
@@ -8,6 +8,7 @@ Source0:   %{name}-%{version}.tar.gz
 
 BuildRequires: cmake
 BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-media-sound-manager)
 BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(edje)
index 1647e94..0bc8f04 100644 (file)
@@ -40,7 +40,7 @@ struct _appdata {
        Eina_Bool visibility;
 };
 
-Eina_Bool _hide_timer(void *data);
+static Eina_Bool _hide_timer(void *data);
 
 Evas_Object *_add_win(const char *name)
 {
@@ -226,6 +226,7 @@ static void _key_pressed(void *data, Evas *e, Evas_Object *obj, void *ei)
        } else if (!strcmp(ev->keyname, KEY_MUTE) ||
                        !strcmp(ev->keyname, KEY_MUTE_REMOTE)) {
                bool mute = !volume_is_mute();
+
                volume_set_mute(mute);
 
                _update_volume_info(ad);
@@ -244,6 +245,8 @@ static bool _create(void *data)
                return false;
        }
 
+       volume_init();
+
        ad = data;
 
        elm_theme_overlay_add(NULL, THEMEFILE);
index 3cf8327..17a282d 100644 (file)
  */
 
 #include <app_debug.h>
+#include <sound_manager.h>
 
 #include "define.h"
 #include "volume.h"
 
-/* FIXME : Temporal code for UI test */
-static int volume = 10;
-static bool mute = false;
+static bool mute;
+static int volume;
+
+void volume_init(void)
+{
+       int r;
+
+       r = volume_get_volume();
+       if (r < 0)
+               volume = VOLUME_DEFAULT;
+       else
+               volume = r;
+
+       mute = false;
+}
 
 int volume_set_mute(bool is_mute)
 {
        mute = is_mute;
 
+       if (mute)
+               sound_manager_set_volume(SOUND_TYPE_MEDIA, MUTE_VALUE);
+       else
+               sound_manager_set_volume(SOUND_TYPE_MEDIA, volume);
+
        return 0;
 }
 
@@ -35,20 +53,34 @@ bool volume_is_mute(void)
        return mute;
 }
 
-int volume_set_volume(int level)
+int volume_set_volume(int vol)
 {
-       if (level < VOLUME_MIN ||
-                       level > VOLUME_MAX) {
+       int r;
+
+       if (vol < VOLUME_MIN ||
+                       vol > VOLUME_MAX) {
                _ERR("volume value out of range");
                return -1;
        }
 
-       volume = level;
+       r = sound_manager_set_volume(SOUND_TYPE_MEDIA, vol);
+       if (r < 0) {
+               _ERR("failed to set volume");
+               return -1;
+       }
+
+       volume = vol;
 
        return 0;
 }
 
 int volume_get_volume(void)
 {
-       return volume;
+       int vol, r;
+
+       r = sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol);
+       if (r < 0)
+               return -1;
+
+       return vol;
 }