aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audiomanager_proxy.c78
-rw-r--r--src/soundmanager.c21
2 files changed, 60 insertions, 39 deletions
diff --git a/src/audiomanager_proxy.c b/src/audiomanager_proxy.c
index 0ce63ec..2d7605b 100644
--- a/src/audiomanager_proxy.c
+++ b/src/audiomanager_proxy.c
@@ -459,7 +459,6 @@ ErrorCode am_proxy_register_domain(GVariant* domain_data, int *domain){
ErrorCode ec;
GError *err = NULL;
- AFB_DEBUG("Call %s", __FUNCTION__);
assert(am_route_bus != NULL);
assert(domain_data);
AFB_DEBUG("Call %s", __FUNCTION__);
@@ -496,7 +495,7 @@ GVariant* create_domain_data(struct domain_data* domain){
}
GVariant* create_source_data(int sourceID, int domainID, const char* appname, int sourceClassID,
- int sourceState, int volume, bool visible, struct availability_s availables,
+ int sourceState, int volume, bool visible, struct availability_s availables,
int interrupt, struct sound_property_s soundPropertyList, int connectionFormatList,
struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting,
struct notification_config_s NConfCommand)
@@ -629,37 +628,8 @@ void set_event_callback(const am_event* callback){
static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data){
GError* error = NULL;
AFB_DEBUG("%s is called", __FUNCTION__);
- guint id = g_dbus_connection_register_object(connection,
- SOUND_MANAGER_PATH, NULL, NULL, NULL, NULL, &error);
- // we don't export interface other than AudioManager so user can't introspect soundmanager method
- if(id < 1){
- AFB_ERROR("Failed to register soundmanager: %s", error->message);
- }
- AFB_DEBUG("register soundmanager path");
-}
-
-static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data){
- AFB_DEBUG("%s is called", __FUNCTION__);
-}
-
-static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data){
- AFB_DEBUG("bus name is lost");
- // TODO: soundmanager should register current status?
-}
+ am_instruction *callback = (am_instruction *)user_data;
-ErrorCode open_soundmanager_interface(const am_instruction *callback){
- guint ret = g_bus_own_name(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
- // see https://developer.gnome.org/gio/stable/gio-Owning-Bus-Names.html#g-bus-own-name
- AFB_DEBUG( "g_bus_own_name ret: %d", ret);
- GError *error = NULL;;
- GVariant *value;
- system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (error)
- {
- g_error_free(error);
- return NOT_INITIALIZED;
- }
sm_adapter = audiomanager_routing_soundmanager_skeleton_new();
sm_itf = AUDIOMANAGER_ROUTING_SOUNDMANAGER_GET_IFACE(sm_adapter);
@@ -681,16 +651,54 @@ ErrorCode open_soundmanager_interface(const am_instruction *callback){
sigret = g_signal_connect(sm_adapter, "handle-async-disconnect", G_CALLBACK(_on_async_disconnect),NULL);
sigret = g_signal_connect(sm_adapter, "handle-async-set-sink-volume", G_CALLBACK(_on_async_set_sink_volume),NULL);
sigret = g_signal_connect(sm_adapter, "handle-async-set-source-state", G_CALLBACK(_on_async_set_source_state),NULL);
- gboolean rc = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), system_conn, SOUND_MANAGER_PATH, &error);
+
+ AFB_DEBUG("register %s", AUDIOMANAGER_ROUTING_SOUNDMANAGER_SKELETON(sm_adapter));
+ guint id = g_dbus_connection_register_object(connection,
+ SOUND_MANAGER_PATH,
+ audiomanager_routing_soundmanager_interface_info(),
+ NULL,
+ NULL, NULL, &error);
+ // we don't export interface other than AudioManager so user can't introspect soundmanager method
+ if(id < 1){
+ AFB_ERROR("Failed to register soundmanager: %s", error->message);
+ }
+ AFB_DEBUG("register soundmanager path");
+
+ gboolean rc = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(sm_adapter), connection, SOUND_MANAGER_PATH, &error);
AFB_DEBUG("export soundmanager path result: %d", rc);
if (FALSE == rc)
{
AFB_ERROR( "failed to export");
g_error_free(error);
- g_object_unref(system_conn);
+ g_object_unref(connection);
- return NOT_INITIALIZED;
+ //return NOT_INITIALIZED;
}
+}
+
+static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data){
+ AFB_DEBUG("%s is called", __FUNCTION__);
+}
+
+static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data){
+ AFB_DEBUG("bus name is lost");
+ // TODO: soundmanager should register current status?
+}
+
+ErrorCode open_soundmanager_interface(const am_instruction *callback){
+ /* guint ret = g_bus_own_name_on_connection(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired, on_name_acquired, on_name_lost, (gpointer)callback, NULL); */
+ guint ret = g_bus_own_name(G_BUS_TYPE_SYSTEM, SOUND_MANAGER_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
+ on_bus_acquired, on_name_acquired, on_name_lost, (gpointer)callback, NULL);
+ // see https://developer.gnome.org/gio/stable/gio-Owning-Bus-Names.html#g-bus-own-name
+ AFB_DEBUG( "g_bus_own_name ret: %d", ret);
+
+ /* system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error)
+ {
+ g_error_free(error);
+ return NOT_INITIALIZED;
+ } */
return OK;
}
diff --git a/src/soundmanager.c b/src/soundmanager.c
index 84ed345..1e34ce6 100644
--- a/src/soundmanager.c
+++ b/src/soundmanager.c
@@ -850,9 +850,7 @@ static void on_new_main_connection(void* closure, int mainConnectioID,
KEY_SINK_ID, sinkID,
KEY_DELAY, delay,
KEY_CONNECTION_STATE, connectionState);
- AFB_DEBUG("json object :%s:",json_object_to_json_string(res_obj));
-
- afb_event_push(ev_new_connection, res_obj);
+ afb_event_push(ev_new_connection, res_obj);
}
static void on_removed_main_connection(void* closure, int mainConnectionID)
@@ -1040,6 +1038,13 @@ int preinit()
AFB_NOTICE( "Finish Initialize");
return 0;
}
+//test
+#include <pthread.h>
+static void *dbus_event_loop_run(void *args)
+{
+ GMainLoop* loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(loop);
+}
int sm_init()
{
@@ -1047,6 +1052,7 @@ int sm_init()
/* Initialize make event */
size_t size = sizeof cmd_evlist / sizeof *cmd_evlist;
+ ErrorCode ec;
/*create event*/
/*ToDo Hash table is better. And event should be created in the loop
@@ -1116,7 +1122,7 @@ int sm_init()
.on_async_set_sink_volume = on_async_set_sink_volume,
.on_async_set_source_state = on_async_set_source_state
};
- ErrorCode ec = open_soundmanager_interface(&instruction);
+ ec = open_soundmanager_interface(&instruction);
if(ec != OK){
AFB_ERROR("Failed to create sound manager interface");
return -1;
@@ -1141,6 +1147,13 @@ int sm_init()
return -1;
}
AFB_DEBUG("domainID : %d", SOUNDMANAGER_DOMAIN_ID);
+ // tes
+ pthread_t thread_id;
+ int ret = pthread_create(&thread_id, NULL, dbus_event_loop_run, NULL);
+ if(ret != 0)
+ {
+ AFB_ERROR("Failed to create thread");
+ }
return 0;
}