device-manager : avail-mode for bt 69/86569/11
authorMok Jeongho <jho.mok@samsung.com>
Thu, 1 Sep 2016 10:33:43 +0000 (19:33 +0900)
committerMok Jeongho <jho.mok@samsung.com>
Tue, 27 Sep 2016 04:26:50 +0000 (13:26 +0900)
[Version] 5.0.80
[Profile] Common
[Issue Type] API

Change-Id: Iab8597b1eefde9f8f31eff69cc144d86a5d70c30

packaging/pulseaudio-modules-tizen.spec
src/communicator.h
src/device-manager.c
src/module-tizenaudio-policy.c
src/stream-manager.c
src/subscribe-observer.c
src/subscribe-observer.h
src/tizen-device-def.h
src/tizen-device.c
src/tizen-device.h

index 64232a41561dc95c48c6649fcd52deed222083b1..24dda5ed2e98ad3d90ddb64feef8e10eea865216 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.79
+Version:          5.0.80
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 8f75be8c528448e780f89c6a4658f8770805c2b7..849c6bebefd458b2aae5ad59e74e1d0c626f588f 100644 (file)
@@ -28,7 +28,8 @@ typedef enum pa_communicator_hook {
     PA_COMMUNICATOR_HOOK_SELECT_INIT_SINK_OR_SOURCE, /* It is fired when a stream is created and needs to be set to sink or source */
     PA_COMMUNICATOR_HOOK_CHANGE_ROUTE,               /* It is fired when routing using internal codec should be processed */
     PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED,  /* It is fired when a device is connected or disconnected */
-    PA_COMMUNICATOR_HOOK_DEVICE_INFORMATION_CHANGED, /* It is fired when a device's property is changed */
+    PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED,     /* It is fired when a device's profile is changed */
+    PA_COMMUNICATOR_HOOK_DEVICE_STATE_CHANGED,       /* It is fired when a device's state is changed */
     PA_COMMUNICATOR_HOOK_EVENT_FULLY_HANDLED,        /* It is fired when a event is handled by all subscribers */
     PA_COMMUNICATOR_HOOK_UPDATE_INFORMATION,         /* It is fired when information should be updated */
     PA_COMMUNICATOR_HOOK_MAX
index 3cbd7c9ff199be43e5705e52636f8ba38d58869a..f0f3b969156daa9fc3ea9f201204ea8a5ca984e4 100644 (file)
     " <interface name=\"" DBUS_INTERFACE_DEVICE_MANAGER "\">\n"                             \
     "  <method name=\"GetConnectedDeviceList\">\n"                                          \
     "   <arg name=\"mask_flags\" direction=\"in\" type=\"i\"/>\n"                           \
-    "   <arg name=\"ConnectedDeviceList\" direction=\"out\" type=\"a(iiiis)\"/>\n"          \
+    "   <arg name=\"ConnectedDeviceList\" direction=\"out\" type=\"a(isiiis)\"/>\n"          \
     "  </method>\n"                                                                         \
     "  <method name='GetBTA2DPStatus'>"                                                     \
     "    <arg type='b' name='is_bt_on' direction='out'/>"                                   \
@@ -285,6 +285,18 @@ typedef enum {
     DEVICE_STATE_FLAGS               = 0xF000,  /**< Flag for device state */
 } device_flags_type_t;
 
+typedef enum dm_device_bt_mode_type {
+    DM_DEVICE_BT_MODE_MEDIA = 0x1,
+    DM_DEVICE_BT_MODE_VOICE = 0x2
+} dm_device_bt_mode_t;
+
+typedef enum dm_device_changed_into_type {
+    DM_DEVICE_CHANGED_INFO_STATE,
+    DM_DEVICE_CHANGED_INFO_IO_DIRECTION,
+    DM_DEVICE_CHANGED_INFO_BT_AVAIL_MODE,
+    DM_DEVICE_CHANGED_INFO_MAX
+} dm_device_changed_info_t;
+
 
 /*
     Structure to save parsed information about device-file.
@@ -353,7 +365,8 @@ struct pa_device_manager {
     pa_core *core;
     pa_hook_slot *sink_put_hook_slot, *sink_state_changed_slot, *sink_unlink_hook_slot;
     pa_hook_slot *source_put_hook_slot, *source_state_changed_slot, *source_unlink_hook_slot;
-    pa_hook_slot *comm_hook_device_connection_changed_slot, *comm_hook_device_info_changed_slot;
+    pa_hook_slot *comm_hook_device_connection_changed_slot, *comm_hook_device_profile_changed_slot;
+    pa_hook_slot *comm_hook_device_state_changed_slot;
     pa_communicator *comm;
 
     /*
@@ -415,14 +428,6 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = {
         .receive_cb = handle_test_device_status_change},
 };
 
-/*** Defines for signal send ***/
-
-enum signal_index {
-    SIGNAL_DEVICE_CONNECTED,
-    SIGNAL_DEVICE_INFO_CHANGED,
-    SIGNAL_MAX
-};
-
 #endif
 
 static void type_info_free_func(struct device_type_info *type_info) {
@@ -1503,7 +1508,7 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
 
 
 
-static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *pdevice, pa_device_manager *dm) {
+static pa_hook_result_t sink_source_state_changed_hook_cb(pa_core *c, pa_object *pdevice, pa_device_manager *dm) {
     pa_tz_device *device;
     bool use_internal_codec = false;
     uint32_t idx = 0;
@@ -1553,7 +1558,7 @@ static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *pdev
             }
         }
     }
-    pa_log_debug("========= device_state_changed_hook_cb END =====");
+    pa_log_debug("========= sink_source_state_changed_hook_cb END =====");
 
     return PA_HOOK_OK;
 }
@@ -2592,19 +2597,39 @@ static void unwatch_signals(pa_device_manager *dm) {
     dbus_connection_remove_filter(pa_dbus_connection_get(dm->dbus_conn), dbus_filter_device_detect_handler, dm);
 }
 
+static int _get_avail_mode(pa_tz_device *device) {
+    int avail_mode = 0;
+    char *type;
+
+    pa_assert(device);
+
+    type = pa_tz_device_get_type(device);
+    if (pa_streq(type, DEVICE_TYPE_BT) == false) {
+        pa_log_debug("Not BT device");
+        return 0;
+    }
+
+    if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_SCO))
+        avail_mode |= DM_DEVICE_BT_MODE_VOICE;
+    if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP))
+        avail_mode |= DM_DEVICE_BT_MODE_MEDIA;
+
+    return avail_mode;
+}
 
 static void send_device_connected_signal(uint32_t event_id, pa_tz_device *device, bool connected, pa_device_manager *dm) {
     DBusMessage *signal_msg;
     DBusMessageIter msg_iter, device_iter;
     dbus_bool_t _connected = connected;
     dm_device_state_t compound_state;
-    dbus_int32_t device_id, direction;
+    dbus_int32_t device_id, direction, avail_mode;
     char *type, *name;
 
     pa_assert(device);
     pa_assert(dm);
 
-    pa_log_info("Send following device %s signal", connected ? "Connected" : "Disconnected");
+    pa_log_info("Send device %s signal, event_id(%u) device(%u)",
+            connected ? "Connected" : "Disconnected", event_id, device->id);
 
     pa_assert_se(signal_msg = dbus_message_new_signal(DBUS_OBJECT_DEVICE_MANAGER, DBUS_INTERFACE_DEVICE_MANAGER, "DeviceConnected"));
     dbus_message_iter_init_append(signal_msg, &msg_iter);
@@ -2614,6 +2639,7 @@ static void send_device_connected_signal(uint32_t event_id, pa_tz_device *device
     direction = (dbus_int32_t) pa_tz_device_get_direction(device);
     type = pa_tz_device_get_type(device);
     name = pa_tz_device_get_name(device);
+    avail_mode = _get_avail_mode(device);
 
     device_id = (dbus_int32_t) pa_tz_device_get_id(device);
     compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
@@ -2621,6 +2647,7 @@ static void send_device_connected_signal(uint32_t event_id, pa_tz_device *device
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
+    dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
     pa_assert_se(dbus_message_iter_close_container(&msg_iter, &device_iter));
     dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_BOOLEAN, &_connected);
@@ -2634,13 +2661,14 @@ static void send_device_info_changed_signal(uint32_t event_id, pa_tz_device *dev
     DBusMessage *signal_msg;
     DBusMessageIter msg_iter, device_iter;
     dm_device_state_t compound_state;
-    dbus_int32_t device_id, direction;
+    dbus_int32_t device_id, direction, avail_mode;
     char *type, *name;
 
     pa_assert(device);
     pa_assert(dm);
 
-    pa_log_debug("Send following device info changed signal");
+    pa_log_debug("Send device info changed signal, event_id(%u) device(%u) changed_type(%d)",
+            event_id, device->id, changed_type);
 
     pa_assert_se(signal_msg = dbus_message_new_signal(DBUS_OBJECT_DEVICE_MANAGER, DBUS_INTERFACE_DEVICE_MANAGER, "DeviceInfoChanged"));
     dbus_message_iter_init_append(signal_msg, &msg_iter);
@@ -2652,11 +2680,13 @@ static void send_device_info_changed_signal(uint32_t event_id, pa_tz_device *dev
     name = pa_tz_device_get_name(device);
     device_id = (dbus_int32_t) pa_tz_device_get_id(device);
     compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
+    avail_mode = (dbus_int32_t) _get_avail_mode(device);
 
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &device_id);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
+    dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
     dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
     pa_assert_se(dbus_message_iter_close_container(&msg_iter, &device_iter));
     dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_INT32, &changed_type);
@@ -2767,7 +2797,7 @@ static void handle_get_connected_device_list(DBusConnection *conn, DBusMessage *
     pa_tz_device *device;
     dm_device_state_t compound_state;
     uint32_t device_idx;
-    dbus_int32_t device_id, direction;
+    dbus_int32_t device_id, direction, avail_mode;
     int mask_flags;
     char *type, *name;
 
@@ -2786,13 +2816,14 @@ static void handle_get_connected_device_list(DBusConnection *conn, DBusMessage *
                                        DBUS_TYPE_INVALID));
 
     dbus_message_iter_init_append(reply, &msg_iter);
-    pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiis)", &array_iter));
+    pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiiis)", &array_iter));
 
     PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
         compound_state = pa_tz_device_get_state(device, DM_DEVICE_DIRECTION_BOTH);
         direction = pa_tz_device_get_direction(device);
         type = pa_tz_device_get_type(device);
         name = pa_tz_device_get_name(device);
+        avail_mode = _get_avail_mode(device);
         if (device_item_match_for_mask(device,  mask_flags, dm)) {
             device_id = (dbus_int32_t)pa_tz_device_get_id(device);
             pa_assert_se(dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &device_iter));
@@ -2800,6 +2831,7 @@ static void handle_get_connected_device_list(DBusConnection *conn, DBusMessage *
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &type);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &direction);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &compound_state);
+            dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_INT32, &avail_mode);
             dbus_message_iter_append_basic(&device_iter, DBUS_TYPE_STRING, &name);
             pa_assert_se(dbus_message_iter_close_container(&array_iter, &device_iter));
         }
@@ -3200,13 +3232,19 @@ fail:
     return -1;
 }
 
-static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_conn_changed *data, pa_device_manager *dm) {
+static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_conn_changed *data, pa_device_manager *dm) {
     send_device_connected_signal(data->event_id, data->device, data->is_connected, dm);
     return PA_HOOK_OK;
 }
 
-static pa_hook_result_t device_info_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_info_changed *data, pa_device_manager *dm) {
-    send_device_info_changed_signal(data->event_id, data->device, data->changed_info, dm);
+static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *data, pa_device_manager *dm) {
+    if (data->changed == PA_TZ_DEVICE_PROFILE_ADDED || data->changed == PA_TZ_DEVICE_PROFILE_REMOVED)
+        send_device_info_changed_signal(data->event_id, data->device, DM_DEVICE_CHANGED_INFO_BT_AVAIL_MODE, dm);
+    return PA_HOOK_OK;
+}
+
+static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_state_changed *data, pa_device_manager *dm) {
+    send_device_info_changed_signal(data->event_id, data->device, DM_DEVICE_CHANGED_INFO_STATE, dm);
     return PA_HOOK_OK;
 }
 
@@ -3229,16 +3267,18 @@ pa_device_manager* pa_device_manager_get(pa_core *c) {
     dbus_init(dm);
 
     dm->sink_put_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE+10, (pa_hook_cb_t) sink_put_hook_callback, dm);
-    dm->sink_state_changed_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) device_state_changed_hook_cb, dm);
+    dm->sink_state_changed_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_source_state_changed_hook_cb, dm);
     dm->sink_unlink_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) sink_unlink_hook_callback, dm);
     dm->source_put_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_LATE+10, (pa_hook_cb_t) source_put_hook_callback, dm);
-    dm->source_state_changed_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) device_state_changed_hook_cb, dm);
+    dm->source_state_changed_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_source_state_changed_hook_cb, dm);
     dm->source_unlink_hook_slot = pa_hook_connect(&dm->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) source_unlink_hook_callback, dm);
     dm->comm = pa_communicator_get(dm->core);
     dm->comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
             PA_HOOK_EARLY, (pa_hook_cb_t)device_connection_changed_hook_cb, dm);
-    dm->comm_hook_device_info_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_INFORMATION_CHANGED),
-            PA_HOOK_EARLY, (pa_hook_cb_t)device_info_changed_hook_cb, dm);
+    dm->comm_hook_device_profile_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
+            PA_HOOK_EARLY, (pa_hook_cb_t)device_profile_changed_hook_cb, dm);
+    dm->comm_hook_device_state_changed_slot = pa_hook_connect(pa_communicator_hook(dm->comm, PA_COMMUNICATOR_HOOK_DEVICE_STATE_CHANGED),
+            PA_HOOK_EARLY, (pa_hook_cb_t)device_state_changed_hook_cb, dm);
     if (!(dm->type_infos = parse_device_type_infos())) {
         pa_log_error("Parse device-type-map failed");
         return NULL;
@@ -3289,8 +3329,10 @@ void pa_device_manager_unref(pa_device_manager *dm) {
 
     if (dm->comm_hook_device_connection_changed_slot)
         pa_hook_slot_free(dm->comm_hook_device_connection_changed_slot);
-    if (dm->comm_hook_device_info_changed_slot)
-        pa_hook_slot_free(dm->comm_hook_device_info_changed_slot);
+    if (dm->comm_hook_device_profile_changed_slot)
+        pa_hook_slot_free(dm->comm_hook_device_profile_changed_slot);
+    if (dm->comm_hook_device_state_changed_slot)
+        pa_hook_slot_free(dm->comm_hook_device_state_changed_slot);
     if (dm->sink_put_hook_slot)
         pa_hook_slot_free(dm->sink_put_hook_slot);
     if (dm->sink_state_changed_slot)
index fe46d7a1e266f9990e83de1f8e83d04b3b9db266..51456c6667424cbd28a654582abf825e5da31410 100644 (file)
@@ -156,7 +156,7 @@ struct userdata {
         pa_hook_slot *comm_hook_select_proper_sink_or_source_slot;
         pa_hook_slot *comm_hook_change_route_slot;
         pa_hook_slot *comm_hook_device_connection_changed_slot;
-        pa_hook_slot *comm_hook_device_info_changed_slot;
+        pa_hook_slot *comm_hook_device_profile_changed_slot;
         pa_hook_slot *comm_hook_update_info_slot;
     } communicator;
 
@@ -1130,7 +1130,7 @@ static void dump_connected_devices()
 }
 
 /* Reorganize routing when a device has been connected or disconnected */
-static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_conn_changed *conn, struct userdata *u) {
+static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_conn_changed *conn, struct userdata *u) {
     uint32_t idx = 0;
     pa_sink_input *s = NULL;
     dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
@@ -1223,7 +1223,7 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_device_
 }
 
 /* Update connected device list when a device's information has been changed */
-static pa_hook_result_t device_info_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_info_changed *conn, struct userdata *u) {
+static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, struct userdata *u) {
     dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
     int* ptr_in = NULL;
     int* ptr_out = NULL;
@@ -1234,10 +1234,10 @@ static pa_hook_result_t device_info_changed_hook_cb(pa_core *c, pa_device_manage
 
     device_direction = pa_tz_device_get_direction(conn->device);
 
-    pa_log_info("[CONN] device_info_changed_hook_cb is called. conn(%p), changed_info(%d), device(%p), direction(0x%x)",
-                conn, conn->changed_info, conn->device, device_direction);
+    pa_log_info("[CONN] device_profile_changed_hook_cb is called. conn(%p), changed(%d), device(%p), direction(0x%x)",
+                conn, conn->changed, conn->device, device_direction);
 
-    if (conn->changed_info == DM_DEVICE_CHANGED_INFO_IO_DIRECTION)
+    if (conn->changed == PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED)
         if (pa_streq(pa_tz_device_get_type(conn->device), DEVICE_TYPE_BT)) {
             /* In case of the bluetooth, we do not maintain a ref. count of the bluetooth devices.
              * Because bluetooth framework supports only one device simultaneously for audio profile. */
@@ -1283,9 +1283,9 @@ int pa__init(pa_module *m)
         u->communicator.comm_hook_device_connection_changed_slot = pa_hook_connect(
                 pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
                 PA_HOOK_EARLY, (pa_hook_cb_t)device_connection_changed_hook_cb, u);
-        u->communicator.comm_hook_device_info_changed_slot = pa_hook_connect(
-                pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_DEVICE_INFORMATION_CHANGED),
-                PA_HOOK_EARLY, (pa_hook_cb_t)device_info_changed_hook_cb, u);
+        u->communicator.comm_hook_device_profile_changed_slot = pa_hook_connect(
+                pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
+                PA_HOOK_EARLY, (pa_hook_cb_t)device_profile_changed_hook_cb, u);
         u->communicator.comm_hook_update_info_slot = pa_hook_connect(
                 pa_communicator_hook(u->communicator.comm, PA_COMMUNICATOR_HOOK_UPDATE_INFORMATION),
                 PA_HOOK_EARLY, (pa_hook_cb_t)update_info_hook_cb, u);
@@ -1344,8 +1344,8 @@ void pa__done(pa_module *m)
             pa_hook_slot_free(u->communicator.comm_hook_change_route_slot);
         if (u->communicator.comm_hook_device_connection_changed_slot)
             pa_hook_slot_free(u->communicator.comm_hook_device_connection_changed_slot);
-        if (u->communicator.comm_hook_device_info_changed_slot)
-            pa_hook_slot_free(u->communicator.comm_hook_device_info_changed_slot);
+        if (u->communicator.comm_hook_device_profile_changed_slot)
+            pa_hook_slot_free(u->communicator.comm_hook_device_profile_changed_slot);
         if (u->communicator.comm_hook_update_info_slot)
             pa_hook_slot_free(u->communicator.comm_hook_update_info_slot);
         pa_communicator_unref(u->communicator.comm);
index a3566370dce3bf6cb8bbedd793d2633b7d3cc332..13b80ebfd9101ba69a8642d5948e73858da5b447 100644 (file)
@@ -3309,7 +3309,7 @@ static pa_hook_result_t event_fully_handled_hook_cb(pa_core *c, pa_subscribe_obs
 }
 
 /* Reorganize routing when a device has been connected or disconnected */
-static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_conn_changed *data, pa_stream_manager *m) {
+static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_conn_changed *data, pa_stream_manager *m) {
     const char *active_dev = NULL;
     const char *device_type = NULL;
     stream_route_type_t route_type;
index 9e6c8dfebeb621faf381090b09e00b2d7f99f24a..7b13092ea60c27021e6513c9b23dc4991d9f4a3c 100644 (file)
@@ -623,7 +623,7 @@ static void dbus_deinit(pa_subscribe_observer *ob) {
     }
 }
 
-static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_device_manager_hook_data_for_conn_changed *data, pa_subscribe_observer *ob) {
+static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_conn_changed *data, pa_subscribe_observer *ob) {
     struct event *new_event;
     pa_idxset *handled_subscribers;
 
index 62109637d0ed6d63a7ccbabb92648095a8893ccf..96b538f9ed5795818eb463ba79cf691b5e6a63d6 100644 (file)
@@ -41,7 +41,7 @@ typedef enum pa_tizen_event_type {
 typedef struct _hook_data_for_event_handled {
     /* Unique id of event, you can determine what event this is about
      * by comparing this with real event's id.
-     * For example, event_id of pa_device_manager_hook_data_for_conn_changed */
+     * For example, event_id of pa_tz_device_hook_data_for_conn_changed */
     uint32_t event_id;
     pa_tizen_event_t event_type;
 } pa_subscribe_observer_hook_data_for_event_handled;
index e4efdd714414bb6ea07bb4dd1b63ed6b3ddfa926..dedebdf6d41f55d43abccdd940e4aadddbb7aff6 100644 (file)
@@ -33,11 +33,6 @@ typedef enum dm_device_direction_type {
     DM_DEVICE_DIRECTION_BOTH = DM_DEVICE_DIRECTION_IN | DM_DEVICE_DIRECTION_OUT
 } dm_device_direction_t;
 
-typedef enum dm_device_changed_into_type {
-    DM_DEVICE_CHANGED_INFO_STATE,
-    DM_DEVICE_CHANGED_INFO_IO_DIRECTION
-} dm_device_changed_info_t;
-
 typedef enum dm_device_state_type {
     DM_DEVICE_STATE_DEACTIVATED = 0,
     DM_DEVICE_STATE_ACTIVATED
index 7f9012129bab1ed9f826d7faaf0e6589f3f7e5e9..2eabac8ce908b8d578da069cf58d24aae5109847 100644 (file)
@@ -133,33 +133,41 @@ void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level) {
 }
 
 static void notify_device_connection_changed(pa_tz_device *device, bool connected) {
-    pa_device_manager_hook_data_for_conn_changed hook_data;
-    uint32_t event_id;
+    pa_tz_device_hook_data_for_conn_changed hook_data;
 
-    event_id = _new_event_id();
-
-    hook_data.event_id = event_id;
+    hook_data.event_id = _new_event_id();
     hook_data.is_connected = connected;
     hook_data.device = device;
 
-    pa_log_info("Fire hook for device connection changed, device(%u) %s",
-            device->id, connected ? "connected" : "disconnected");
+    pa_log_info("Fire hook for device connection changed, device(%s/%u) %s",
+            device->type, device->id, connected ? "connected" : "disconnected");
     pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED), &hook_data);
 }
 
-static void notify_device_info_changed(pa_tz_device *device, dm_device_changed_info_t changed_type) {
-    pa_device_manager_hook_data_for_info_changed hook_data;
-    uint32_t event_id;
+static void notify_device_profile_changed(pa_tz_device *device, pa_tz_device_profile_changed_t changed_type) {
+    pa_tz_device_hook_data_for_profile_changed hook_data;
+    const char* changed_type_str[PA_TZ_DEVICE_PROFILE_CHANGED_MAX] =
+        {"Profile Added", "Profile Removed", "Active-profile Changed"};
+
+    hook_data.event_id = _new_event_id();
+    hook_data.changed = changed_type;
+    hook_data.device = device;
+
+    pa_log_info("Fire hook for device profile changed, device(%s/%u) %s",
+            device->type, device->id, changed_type_str[changed_type]);
+    pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED), &hook_data);
+}
 
-    event_id = _new_event_id();
+static void notify_device_state_changed(pa_tz_device *device, dm_device_state_t state) {
+    pa_tz_device_hook_data_for_state_changed hook_data;
 
-    hook_data.event_id = event_id;
-    hook_data.changed_info = changed_type;
+    hook_data.event_id = _new_event_id();
+    hook_data.activated = (state == DM_DEVICE_STATE_ACTIVATED) ? true : false;
     hook_data.device = device;
 
-    pa_log_info("Fire hook for device info changed, device(%u) %s changed",
-            device->id, changed_type == DM_DEVICE_CHANGED_INFO_STATE ? "state" : "direction");
-    pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_INFORMATION_CHANGED), &hook_data);
+    pa_log_info("Fire hook for device state changed, device(%s/%u) %s",
+            device->type, device->id, hook_data.activated ? "Activated" : "De-activated");
+    pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_STATE_CHANGED), &hook_data);
 }
 
 /* pa_tz_device_new_data */
@@ -371,7 +379,7 @@ static void profile_set_state(pa_tz_profile *profile, dm_device_direction_t dire
     pa_log_debug("new playback_state : %d, capture_state : %d => state %d", profile->playback_state, profile->capture_state, new_state);
 
     if (prev_state != new_state) {
-        notify_device_info_changed(profile->device, DM_DEVICE_CHANGED_INFO_STATE);
+        notify_device_state_changed(profile->device, new_state);
         pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
     }
 }
@@ -583,7 +591,7 @@ int _set_active_profile(pa_tz_device *device, const char *profile, bool noti_alw
 
     /* Compare index only when check_idx is true */
     if (noti_always || prev_active_idx != device->active_profile)
-        notify_device_info_changed(device, DM_DEVICE_CHANGED_INFO_IO_DIRECTION);
+        notify_device_profile_changed(device, PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED);
 
     return 0;
 }
@@ -613,6 +621,7 @@ int pa_tz_device_add_profile(pa_tz_device *device, pa_tz_profile_new_data *pdata
 
     if (as_active)
         _set_active_profile(device, pdata->profile, true);
+    notify_device_profile_changed(device, PA_TZ_DEVICE_PROFILE_ADDED);
     pa_tz_device_dump_info(device, PA_LOG_INFO);
 
     return 0;
@@ -653,6 +662,7 @@ int pa_tz_device_remove_profile(pa_tz_device *device, const char *profile_str) {
         /* change active profile if removed one was active */
         if (device->active_profile == remove_idx)
             _set_active_profile(device, NULL, true);
+        notify_device_profile_changed(device, PA_TZ_DEVICE_PROFILE_REMOVED);
         pa_tz_device_dump_info(device, PA_LOG_INFO);
         return 0;
     } else {
@@ -1056,6 +1066,8 @@ pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role) {
     return source;
 }
 
+/* TODO : Change param dm_device_state_t to bool or pa_tz_device_state_t,
+ * Because this state represent pa_tz_device's own state */
 void pa_tz_device_set_state(pa_tz_device *device, dm_device_direction_t direction, dm_device_state_t state) {
     pa_tz_profile *profile;
 
index 9cd4f752d9f96ac18965c6a7d7d411c168bba071..0776c98319b91ce4f1442496b371062a98765845 100644 (file)
@@ -9,6 +9,13 @@
 #include <pulsecore/dbus-util.h>
 #endif
 
+typedef enum pa_tz_device_profile_changed_type {
+    PA_TZ_DEVICE_PROFILE_ADDED,
+    PA_TZ_DEVICE_PROFILE_REMOVED,
+    PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED,
+    PA_TZ_DEVICE_PROFILE_CHANGED_MAX
+} pa_tz_device_profile_changed_t;
+
 typedef struct pa_tz_device pa_tz_device;
 typedef struct pa_tz_profile pa_tz_profile;
 typedef struct pa_tz_device_new_data pa_tz_device_new_data;
@@ -122,13 +129,19 @@ typedef struct _hook_call_data_for_conn_changed {
     uint32_t event_id;
     bool is_connected;
     pa_tz_device *device;
-} pa_device_manager_hook_data_for_conn_changed;
+} pa_tz_device_hook_data_for_conn_changed;
+
+typedef struct _hook_call_data_for_profile_changed {
+    uint32_t event_id;
+    pa_tz_device_profile_changed_t changed;
+    pa_tz_device *device;
+} pa_tz_device_hook_data_for_profile_changed;
 
-typedef struct _hook_call_data_for_info_changed {
+typedef struct _hook_call_data_for_state_changed {
     uint32_t event_id;
-    dm_device_changed_info_t changed_info;
+    bool activated;
     pa_tz_device *device;
-} pa_device_manager_hook_data_for_info_changed;
+} pa_tz_device_hook_data_for_state_changed;
 
 /*** For device manager ***/
 void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level);
@@ -196,6 +209,7 @@ pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device);
 bool pa_tz_device_is_use_internal_codec(pa_tz_device *device);
 unsigned pa_tz_device_get_profile_num(pa_tz_device *device);
 bool pa_tz_device_have_profile(pa_tz_device *device, const char *profile);
+int pa_tz_device_get_bt_avail_mode(pa_tz_device *device);
 
 /* Only for BT device
  * Check device type and check also sco profile