Fix invalid power-off operation by parsing state value properly 80/111880/2 accepted/tizen/3.0/common/20170125.121747 accepted/tizen/3.0/ivi/20170125.083959 accepted/tizen/3.0/mobile/20170125.083859 accepted/tizen/3.0/tv/20170125.083926 accepted/tizen/3.0/wearable/20170125.083948 submit/tizen_3.0/20170124.120400
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 24 Jan 2017 11:45:13 +0000 (20:45 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 24 Jan 2017 11:46:45 +0000 (20:46 +0900)
[Version] 5.0.128
[Profile] Common
[Issue Type] Bug

Change-Id: Ieb7ab369483e66971fb7ae19b1b063e2bb1274ed

packaging/pulseaudio-modules-tizen.spec
src/module-poweroff.c

index badf388..298c7aa 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.127
+Version:          5.0.128
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index e1785e6..e5ced63 100644 (file)
@@ -63,6 +63,13 @@ PA_MODULE_LOAD_ONCE(true);
 
 #define STREAM_ROLE_RADIO "radio"
 
+enum deviced_poweroff_type {
+    DEVICED_POWER_OFF_NONE = 0,
+    DEVICED_POWER_OFF_POPUP,
+    DEVICED_POWER_OFF_DIRECT,
+    DEVICED_POWER_OFF_RESTART,
+};
+
 struct userdata {
     pa_module *module;
     pa_dbus_connection *dbus_conn;
@@ -120,6 +127,7 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core, pa_sink_input *i, struc
 
 static DBusHandlerResult _dbus_filter_device_detect_handler(DBusConnection *c, DBusMessage *s, void *userdata) {
     struct userdata *u = (struct userdata *)userdata;
+    int state = 0;
 
     pa_assert(u);
 
@@ -133,9 +141,17 @@ static DBusHandlerResult _dbus_filter_device_detect_handler(DBusConnection *c, D
     pa_log_debug("signature  : %s", dbus_message_get_signature(s));
 
     if (dbus_message_is_signal(s, INTERFACE_NAME, SIGNAL_NAME)) {
-        pa_log_warn("NOW POWEROFF!!!!");
-        u->is_poweroff = true;
-        mute_all_streams(u);
+        if (dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID)) {
+            if (state == DEVICED_POWER_OFF_DIRECT ||
+                state == DEVICED_POWER_OFF_RESTART) {
+                const char* mode_str[] = { "None", "Popup", "Direct", "Restart" };
+                pa_log_warn("---- PowerOff : %s ----", mode_str[state]);
+                u->is_poweroff = true;
+                mute_all_streams(u);
+            }
+        } else
+            pa_log_error("failed to parse state, do nothing!!!");
+
         return DBUS_HANDLER_RESULT_HANDLED;
     }