stream-manager: Save mute state to vconf 26/199826/2 accepted/tizen/unified/20190221.015450 submit/tizen/20190220.021455
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 29 Jan 2019 06:03:19 +0000 (15:03 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 18 Feb 2019 07:04:42 +0000 (16:04 +0900)
[Version] 11.1.32
[Issue type] Enhancement

Change-Id: If866ff2fe8489de4bfd28a4ceb9ccf1df27f7542
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/stream-manager-dbus.c
src/stream-manager-volume-priv.h
src/stream-manager-volume.c

index 89e2287..96a9a01 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.31
+Version:          11.1.32
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index c2047eb..e193bc1 100644 (file)
@@ -689,6 +689,7 @@ static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void
     stream_type_t stream_type = STREAM_SINK_INPUT;
     DBusMessage *reply = NULL;
     pa_stream_manager *m = (pa_stream_manager*)userdata;
+    int ret = 0;
 
     pa_assert(conn);
     pa_assert(msg);
@@ -712,6 +713,12 @@ static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void
         goto finish;
     }
 
+    /* check vconf update here, mute will not be set if update fails */
+    if ((ret = update_mute_vconf(type, do_mute))) {
+        pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID));
+        goto finish;
+    }
+
     if (set_volume_mute_by_type(m, stream_type, type, (bool)do_mute))
         pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID));
     else
index 8d9dc79..097d5e5 100644 (file)
@@ -28,6 +28,7 @@
 #include <vconf-keys.h>
 
 #define VCONFKEY_OUT_VOLUME_PREFIX         "file/private/sound/volume/"
+#define VCONFKEY_OUT_MUTE_PREFIX           "file/private/sound/mute/"
 #define MASTER_VOLUME_TYPE                 "master"
 #define MASTER_VOLUME_LEVEL_MAX            100
 
@@ -48,5 +49,6 @@ int32_t set_volume_mute_by_idx(pa_stream_manager *m, stream_type_t stream_type,
 int32_t set_volume_mute_with_new_data(pa_stream_manager *m, void *stream, stream_type_t stream_type, bool volume_mute);
 int32_t get_volume_mute_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t stream_idx, bool *volume_mute);
 int32_t update_volume_vconf(const char *type, unsigned int value);
+int32_t update_mute_vconf(const char *type, unsigned int mute);
 
 #endif
index 4804264..79f3a6c 100644 (file)
@@ -32,6 +32,7 @@
 #define VOLUME_INI_DEFAULT_PATH     SYSCONFDIR"/multimedia/mmfw_audio_volume.ini" /* SYSCONFDIR is defined at .spec */
 #define VOLUME_INI_TUNED_PATH       "/opt/system/mmfw_audio_volume.ini"
 #define DEFAULT_TABLE               "volumes"
+#define VCONF_PATH_MAX 128
 
 #define CONVERT_TO_HAL_DIRECTION(stream_type)\
     ((stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN)
@@ -229,7 +230,7 @@ static int get_volume_value(pa_stream_manager *m, stream_type_t stream_type, boo
 
 int32_t update_volume_vconf(const char *type, unsigned int value)
 {
-    char str[128];
+    char str[VCONF_PATH_MAX];
 
     pa_snprintf(str, sizeof(str), "%s%s", VCONFKEY_OUT_VOLUME_PREFIX, type);
 
@@ -245,6 +246,24 @@ int32_t update_volume_vconf(const char *type, unsigned int value)
     return 0;
 }
 
+int32_t update_mute_vconf(const char *type, unsigned int mute)
+{
+    char str[VCONF_PATH_MAX];
+
+    pa_snprintf(str, sizeof(str), "%s%s", VCONFKEY_OUT_MUTE_PREFIX, type);
+
+    /* Set mute value to VCONF */
+    if ((vconf_set_bool(str, mute)) != 0) {
+        pa_log_error("vconf_set_bool(%s) failed...errno(%d)",
+                     str, vconf_get_ext_errno());
+        return -1;
+    }
+
+    pa_log_info("mute set type(%s) value(%d)", str, mute);
+
+    return 0;
+}
+
 int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, uint32_t volume_level) {
     bool is_hal_volume = false;
     volume_info *v = NULL;
@@ -738,6 +757,7 @@ int32_t init_volumes(pa_stream_manager *m) {
         char vconf_vol_type_addr[VCONF_ADDR_LEN] = {0,};
         const char *volume_type = NULL;
         int level = 10;
+        int muted = 0;
         state = NULL;
         while ((v = pa_hashmap_iterate(m->volume_infos, &state, (const void**)&volume_type))) {
             memset(vconf_vol_type_addr, 0, VCONF_ADDR_LEN);
@@ -748,6 +768,14 @@ int32_t init_volumes(pa_stream_manager *m) {
                 set_volume_level_by_type(m, STREAM_SINK_INPUT, volume_type, (uint32_t)level);
                 pa_log_debug("type[%s], current level[%u]", volume_type, v->values[STREAM_DIRECTION_OUT].current_level);
             }
+            memset(vconf_vol_type_addr, 0, VCONF_ADDR_LEN);
+            pa_snprintf(vconf_vol_type_addr, VCONF_ADDR_LEN, "%s%s", VCONFKEY_OUT_MUTE_PREFIX, volume_type);
+            if (vconf_get_bool(vconf_vol_type_addr, &muted))
+                pa_log_error("failed to get mute state of the vconf[%s]", vconf_vol_type_addr);
+            else {
+                set_volume_mute_by_type(m, STREAM_SINK_INPUT, volume_type, (bool)muted);
+                pa_log_debug("type[%s], is_muted[%d]", volume_type, v->values[STREAM_DIRECTION_OUT].is_muted);
+            }
         }
     }
 #if 0