From 45f6754bef00113c2d396e690d5eeb264844d7bf Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 8 Sep 2017 10:13:55 +0900 Subject: [PATCH] device-manager: Notify bluetooth asynchronous information for SCO to HAL 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 --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/device-manager.c | 27 ++++++++++++++++++++++++--- src/hal-interface.h | 12 ++++++++++++ src/module-tizenaudio-policy.c | 19 ++++--------------- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 73f18cc..edabf2b 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -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+ diff --git a/src/device-manager.c b/src/device-manager.c index f8e40fd..3aa2ea1 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -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); diff --git a/src/hal-interface.h b/src/hal-interface.h index faebb03..c44b7d6 100644 --- a/src/hal-interface.h +++ b/src/hal-interface.h @@ -24,6 +24,7 @@ #include #include +#include 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); diff --git a/src/module-tizenaudio-policy.c b/src/module-tizenaudio-policy.c index 66ac4cf..13872fa 100644 --- a/src/module-tizenaudio-policy.c +++ b/src/module-tizenaudio-policy.c @@ -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 */ -- 2.7.4