Open dbus connection only when message port callback is registered 35/301235/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Sat, 11 Nov 2023 14:41:56 +0000 (23:41 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Sat, 11 Nov 2023 14:41:59 +0000 (23:41 +0900)
Change-Id: I02689ed9f0e92034305c8de98d2a5bd981d15188

client/ma_dbus.c

index eaa6ac896920e4c0b083bc8a9845114cd752529b..05aa25fa299c4324e39d561f77d732b9e2325dcb 100644 (file)
@@ -160,14 +160,17 @@ static int streaming_ipc_initialize()
 #else
        int port_id = message_port_register_local_port(message_port, message_port_cb, NULL);
 #endif
+       int ret = MA_ERROR_NONE;
+
        if (port_id < 0) {
-               MA_SLOGD("Port register error: %d", port_id); //LCOV_EXCL_LINE
+               MA_SLOGE("Port register error: %d", port_id); //LCOV_EXCL_LINE
+               ret = MA_ERROR_OPERATION_FAILED;
        } else {
                MA_SLOGD("port_id: %d", port_id); //LCOV_EXCL_LINE
                g_local_port_id = port_id;
        }
 
-       return 0;
+       return ret;
 }
 
 static int streaming_ipc_deinitialize()
@@ -547,6 +550,10 @@ static void __ma_dbus_connection_free()
 
 int ma_dbus_open_connection()
 {
+       if (MA_ERROR_NONE != streaming_ipc_initialize()) {
+               return MA_ERROR_OPERATION_FAILED;
+       }
+
        if (NULL != g_conn_sender && NULL != g_conn_listener) {
                MA_SLOGW("already existed connection "); //LCOV_EXCL_LINE
                return 0;
@@ -668,15 +675,11 @@ int ma_dbus_open_connection()
                //LCOV_EXCL_STOP
        }
 
-       streaming_ipc_initialize();
-
        return 0;
 }
 
 int ma_dbus_close_connection()
 {
-       streaming_ipc_deinitialize();
-
        DBusError err;
        dbus_error_init(&err);
 
@@ -704,6 +707,8 @@ int ma_dbus_close_connection()
 
        __ma_dbus_connection_free();
 
+       streaming_ipc_deinitialize();
+
        return 0;
 }
 
@@ -1257,7 +1262,7 @@ int ma_dbus_start_streaming_audio_data(int pid, ma_audio_streaming_data_type_e t
                MA_SLOGE("@@ multi-assistant send streaming request : Fail to make message"); //LCOV_EXCL_LINE
                return MA_ERROR_OPERATION_FAILED;
        } else {
-               MA_SLOGD("[DEBUG] multi-assistant send streaming request"); //LCOV_EXCL_LINE
+               MA_SLOGE("[DEBUG] multi-assistant send streaming request, %d", g_local_port_id); //LCOV_EXCL_LINE
        }
 
        dbus_message_append_args(msg,