Change mainloop to tizen-core 97/307897/3
authorChanggyu Choi <changyu.choi@samsung.com>
Thu, 14 Mar 2024 05:15:39 +0000 (14:15 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Thu, 14 Mar 2024 06:26:11 +0000 (06:26 +0000)
After applying this patch, amd uses tizen-core mainloop instead of gmainloop.

Change-Id: Ide72e7a3856804861898b6c5c06b928e2a4bd1b5
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
CMakeLists.txt
packaging/amd.spec
src/lib/CMakeLists.txt
src/lib/amd_main.cc

index 866803b..d264059 100644 (file)
@@ -81,6 +81,7 @@ PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager)
 PKG_CHECK_MODULES(SENSOR_DEPS REQUIRED sensor)
 PKG_CHECK_MODULES(SQLITE3_DEPS REQUIRED sqlite3)
 PKG_CHECK_MODULES(TANCHOR_DEPS REQUIRED tanchor)
+PKG_CHECK_MODULES(TIZEN_CORE_DEPS REQUIRED tizen-core)
 PKG_CHECK_MODULES(TIZEN_DATABASE_DEPS REQUIRED tizen-database)
 PKG_CHECK_MODULES(TIZEN_EXTENSION_CLIENT_DEPS REQUIRED tizen-extension-client)
 PKG_CHECK_MODULES(TIZEN_LAUNCH_CLIENT_DEPS REQUIRED tizen-launch-client)
index 6cf9168..b603fe9 100644 (file)
@@ -17,6 +17,7 @@ Requires(post):   /usr/bin/systemctl
 Requires(postun): /sbin/ldconfig
 Requires(postun): /usr/bin/systemctl
 Requires(preun):  /usr/bin/systemctl
+Requires:   tizen-core
 Requires:   tizen-platform-config
 
 BuildRequires:  cmake
@@ -46,6 +47,7 @@ BuildRequires:  pkgconfig(security-manager)
 BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(tanchor)
+BuildRequires:  pkgconfig(tizen-core)
 BuildRequires:  pkgconfig(tizen-database)
 BuildRequires:  pkgconfig(tizen-extension-client)
 BuildRequires:  pkgconfig(tizen-launch-client)
index 9443db1..62ef78c 100644 (file)
@@ -82,6 +82,7 @@ APPLY_PKG_CONFIG(${TARGET_LIB_AMD} PUBLIC
   PKGMGR_DEPS
   PKGMGR_INFO_DEPS
   SQLITE3_DEPS
+  TIZEN_CORE_DEPS
   TIZEN_DATABASE_DEPS
   TIZEN_SHARED_QUEUE_DEPS
   TTRACE_DEPS
index 02766fd..528e723 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <systemd/sd-daemon.h>
+#include <tizen_core.h>
 #include <unistd.h>
 
 #include <list>
@@ -255,6 +256,8 @@ static gboolean TimeoutCb(gpointer user_data) {
 extern "C" EXPORT int amd_main(int argc, char** argv) {
   amd::CPUBoostController::DoBoost(getpid(),
       amd::CPUBoostController::Level::Strong, -1);
+  tizen_core_init();
+
   if (Initialize() != 0) {
     _E("AMD initialization is failed");
     return -1;
@@ -272,16 +275,18 @@ extern "C" EXPORT int amd_main(int argc, char** argv) {
         return G_SOURCE_REMOVE;
       }, nullptr);
 
-  GMainLoop* loop = g_main_loop_new(nullptr, FALSE);
-  if (loop == nullptr) {
-    _E("g_main_loop_new() is failed");
+  tizen_core_h core = nullptr;
+  int ret = tizen_core_task_create("main", false, &core);
+  if (ret != TIZEN_CORE_ERROR_NONE) {
+    _E("tizen_core_task_create() is failed. error(%d)", ret);
     return -1;
   }
 
   _W("AMD_LOOP_START");
-  g_main_loop_run(loop);
+  tizen_core_task_run(core);
   _W("AMD_LOOP_END");
-  g_main_loop_unref(loop);
   Finalize();
+
+  tizen_core_shutdown();
   return 0;
 }