Fix log message, and add common function to initialize gdbus module.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gdbus_export_interface (gpointer instance, const char *obj_path)
{
if (g_dbus_sys_conn == NULL) {
- _E ("cannot get the dbus connection to the system message bus\n");
+ _E ("Cannot get the dbus connection to the system message bus");
return -ENOSYS;
}
int
gdbus_get_system_connection (gboolean is_session)
{
- GError *error = NULL;
+ GError *err = NULL;
GBusType bus_type = is_session ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM;
- g_dbus_sys_conn = g_bus_get_sync (bus_type, NULL, &error);
+ g_dbus_sys_conn = g_bus_get_sync (bus_type, NULL, &err);
if (g_dbus_sys_conn == NULL) {
- _E ("cannot connect to the system message bus: %s\n", error->message);
- g_clear_error (&error);
+ _E ("Cannot connect to the system message bus: %s", err ? err->message : "Unknown error");
+ g_clear_error (&err);
return -ENOSYS;
}
{
g_clear_object (&g_dbus_sys_conn);
}
+
+/**
+ * @brief Common function to initialize the DBus module.
+ */
+void
+gdbus_initialize (void)
+{
+ GError *err = NULL;
+
+ if (!gst_init_check (NULL, NULL, &err))
+ _E ("Failed to initialize GStreamer: %s", (err ? err->message : "Unknown error"));
+
+ g_clear_error (&err);
+}
#include <glib.h>
#include <gio/gio.h>
+#include <gst/gst.h>
#include <stdbool.h>
#ifdef __cplusplus
*/
void gdbus_put_system_connection (void);
+/**
+ * @brief Common function to initialize the DBus module.
+ */
+void gdbus_initialize (void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include <errno.h>
#include <glib.h>
-#include <gst/gst.h>
#include "common.h"
#include "dbus-interface.h"
static void
init_model_module (void *data)
{
- GError *err = NULL;
- gboolean ret;
-
- ret = gst_init_check (NULL, NULL, &err);
- if (!ret) {
- _E ("Failed to initialize GStreamer with err msg (%s)", (err ? err->message : "NULL"));
- }
- g_clear_error (&err);
+ gdbus_initialize ();
}
/**
static void
init_pipeline_module (void *data)
{
- GError *err = NULL;
+ gdbus_initialize ();
G_LOCK (pipeline_table_lock);
g_assert (NULL == pipeline_table); /** Internal error */
pipeline_table = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, _pipeline_free);
G_UNLOCK (pipeline_table_lock);
-
- _I ("init gstreamer");
- if (!gst_init_check (NULL, NULL, &err)) {
- if (err) {
- _E ("Initializing gstreamer failed with err msg %s", err->message);
- g_clear_error (&err);
- } else {
- _E ("cannot initialize GStreamer with unknown reason.");
- }
- }
}
/**
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <gst/gst.h>
#include <common.h>
#include <modules.h>
static void
init_test (void *data)
{
- GError *err = NULL;
g_debug ("init_test module");
- if (!gst_init_check (NULL, NULL, &err)) {
- if (err) {
- g_critical ("Initializing gstreamer failed with err msg %s",
- err->message);
- g_clear_error (&err);
- } else {
- g_critical ("cannot initalize GStreamer with unknown reason.");
- }
- }
+ gdbus_initialize ();
}
/**