device-manager: Notify bluetooth asynchronous information for SCO to HAL 57/149257/1 accepted/tizen/unified/20170914.154136 submit/tizen/20170913.051034
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 8 Sep 2017 01:13:55 +0000 (10:13 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 12 Sep 2017 03:09:33 +0000 (03:09 +0000)
Values of 'bt-wideband','bt-nrec','bt-sco-ready' are forwarded to audio HAL

[Version] 5.0.171
[Issue Type] Enhancement

Change-Id: Ifdb28887b5d44aafe3eaf121d2463b6a2bf24c81
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/device-manager.c
src/hal-interface.h
src/module-tizenaudio-policy.c

index 73f18cc..edabf2b 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.170
+Version:          5.0.171
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index f8e40fd..3aa2ea1 100644 (file)
@@ -49,6 +49,7 @@
 #endif
 
 #include "communicator.h"
+#include "hal-interface.h"
 #include "device-manager.h"
 
 #define SHARED_DEVICE_MANAGER "tizen-device-manager"
@@ -274,7 +275,6 @@ typedef enum dm_device_class_type {
     DM_DEVICE_CLASS_MAX,
 } dm_device_class_t;
 
-
 typedef enum {
     DEVICE_IO_DIRECTION_IN_FLAG      = 0x0001,  /**< Flag for input devices */
     DEVICE_IO_DIRECTION_OUT_FLAG     = 0x0002,  /**< Flag for output devices */
@@ -372,6 +372,7 @@ struct pa_device_manager {
     pa_hook_slot *comm_hook_device_connection_changed_slot;
     pa_hook_slot *comm_hook_device_state_changed_slot;
     pa_communicator *comm;
+    pa_hal_interface *hal_interface;
 
     /*
        Idxset for save parsed information about device-type.
@@ -391,7 +392,6 @@ struct pa_device_manager {
     pa_dbus_connection *dbus_conn;
 };
 
-
 struct composite_type {
     const char *type;
     const char *role;
@@ -2522,6 +2522,22 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB
                 }
                 handle_device_status_changed(dm, DEVICE_TYPE_BT_SCO,
                         name, dbus_message_get_path(s),  detected);
+            } else if (pa_streq(property_name, "Playing")) {
+                pa_log_info("SCO Playing : %d", value);
+                if (value) {
+                    /* update BT band/nrec information */
+                    pa_tz_device *device;
+                    if ((device = _device_list_get_device(dm, DEVICE_TYPE_BT_SCO, NULL)) != NULL) {
+                        bool is_wide_band = false;
+                        bool nrec = false;
+                        pa_tz_device_sco_get_property(device, &is_wide_band, &nrec);
+                        pa_log_info("got new wideband:%d, nrec:%d", is_wide_band, nrec);
+
+                        UPDATE_HAL_ROUTE_OPTION(dm->hal_interface, NULL, "bt-wideband", is_wide_band);
+                        UPDATE_HAL_ROUTE_OPTION(dm->hal_interface, NULL, "bt-nrec", nrec);
+                    }
+                }
+                UPDATE_HAL_ROUTE_OPTION(dm->hal_interface, NULL, "bt-sco-ready", value);
             }
         }
     } else {
@@ -3543,6 +3559,9 @@ pa_device_manager* pa_device_manager_get(pa_core *c) {
             PA_HOOK_EARLY, (pa_hook_cb_t)device_connection_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);
+
+    dm->hal_interface = pa_hal_interface_get(dm->core);
+
     if (!(dm->type_infos = parse_device_type_infos())) {
         pa_log_error("Parse device-type-map failed");
         return NULL;
@@ -3604,6 +3623,9 @@ void pa_device_manager_unref(pa_device_manager *dm) {
     if (dm->source_unlink_hook_slot)
         pa_hook_slot_free(dm->source_unlink_hook_slot);
 
+    if (dm->hal_interface)
+        pa_hal_interface_unref(dm->hal_interface);
+
     if (dm->comm)
         pa_communicator_unref(dm->comm);
 
@@ -3623,7 +3645,6 @@ void pa_device_manager_unref(pa_device_manager *dm) {
 
     dbus_deinit(dm);
 
-
     if (dm->core)
         pa_shared_remove(dm->core, SHARED_DEVICE_MANAGER);
 
index faebb03..c44b7d6 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <dlfcn.h>
 #include <pulsecore/core.h>
+#include <pulsecore/macro.h>
 
 typedef struct _pa_hal_interface pa_hal_interface;
 
@@ -65,6 +66,17 @@ typedef struct _hal_stream_info {
 
 typedef void* pcm_handle;
 
+#define UPDATE_HAL_ROUTE_OPTION(x_hal_intf, x_role, x_name, x_value) \
+do { \
+    pa_assert(x_hal_intf); \
+    hal_route_option route_option; \
+    memset(&route_option, 0, sizeof(hal_route_option)); \
+    route_option.role = x_role; \
+    route_option.name = x_name; \
+    route_option.value = x_value; \
+    pa_hal_interface_update_route_option(x_hal_intf, &route_option); \
+} while (0) \
+
 #define MSG_FOR_LOOPBACK_ARG_LATENCY      "loopback::latency"
 #define MSG_FOR_LOOPBACK_ARG_ADJUST_TIME  "loopback::adjust_time"
 typedef void (*hal_message_callback)(const char *name, int value, void *user_data);
index 66ac4cf..13872fa 100644 (file)
@@ -213,18 +213,6 @@ static void __load_dump_config(struct userdata *u)
     }
 }
 
-static void update_hal_route_option(pa_hal_interface *hal_intf, const char *role, const char* name, int value)
-{
-    hal_route_option route_option;
-
-    memset(&route_option, 0, sizeof(hal_route_option));
-    route_option.role = role;
-    route_option.name = name;
-    route_option.value = value;
-
-    pa_hal_interface_update_route_option(hal_intf, &route_option);
-}
-
 /* threre is only one sco connected device */
 static pa_tz_device* _get_sco_connected_device(pa_device_manager *dm) {
     pa_idxset *device_list;
@@ -461,10 +449,11 @@ static void update_bt_sco_option(struct userdata *u, const char* role) {
 
     if (get_bt_property(u->device_manager, &is_wb, &is_nrec) == 0) {
         pa_log_info("bt property : wideband(%d), nrec(%d)", is_wb, is_nrec);
-        update_hal_route_option(u->hal_interface, role, "bt-wideband", (int)is_wb);
-        update_hal_route_option(u->hal_interface, role, "bt-nrec", (int)is_nrec);
-    } else
+        UPDATE_HAL_ROUTE_OPTION(u->hal_interface, role, "bt-wideband", (int)is_wb);
+        UPDATE_HAL_ROUTE_OPTION(u->hal_interface, role, "bt-nrec", (int)is_nrec);
+    } else {
         pa_log_warn("Failed to get property for wideband / nrec....");
+    }
 }
 
 /* Load/Unload module-loopback */