Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
-Version: 5.0.97
+Version: 5.0.98
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
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_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 */
#define SHARED_DEVICE_MANAGER "tizen-device-manager"
#define DEVICE_MAP_FILE "/etc/pulse/device-map.json"
-#define DEVICE_PROFILE_MAX 2
#define DEVICE_STR_MAX 30
#define DEVICE_DIRECTION_MAX 3
#define DEVICE_PARAM_STRING_MAX 150
#define DEVICE_FILE_PER_TYPE_MAX 4
#define DEVICE_FILE_STRING_MAX 4
#define DEVICE_TYPE_STR_MAX 20
-#define DEVICE_PROFILE_STR_MAX 5
#define DEVICE_ROLE_STR_MAX 15
#define DEVICE_TYPE_OBJECT "device-types"
" <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(isiiis)\"/>\n" \
+ " <arg name=\"ConnectedDeviceList\" direction=\"out\" type=\"a(isiis)\"/>\n" \
" </method>\n" \
" <method name='GetBTA2DPStatus'>" \
" <arg type='b' name='is_bt_on' direction='out'/>" \
" </method>" \
" <method name=\"LoadSink\">\n" \
" <arg name=\"device_type\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"device_profile\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"role\" direction=\"in\" type=\"s\"/>\n" \
" </method>\n" \
" <method name=\"TestStatusChange\">\n" \
" <arg name=\"device_type\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"device_profile\" direction=\"in\" type=\"s\"/>\n" \
" <arg name=\"status\" direction=\"in\" type=\"i\"/>\n" \
" </method>\n" \
" <property name=\"PropertyTest1\" type=\"i\" access=\"readwrite\"/>\n" \
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 for represent device-types(ex. builtin-speaker) properties*/
struct device_type_info {
const char *type;
- const char *profile;
/*
For save supported roles and related device-file.
{ key:role -> value:device_string ]
struct device_status_info {
char *type;
- char *profile;
char *name;
/* Identify devices among same device-types (for multi-device), currently not works*/
char *system_id;
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_profile_changed_slot;
+ pa_hook_slot *comm_hook_device_connection_changed_slot;
pa_hook_slot *comm_hook_device_state_changed_slot;
pa_communicator *comm;
struct composite_type {
const char *type;
- const char *profile;
const char *role;
};
#endif
-static inline void simple_device_dump(pa_log_level_t level, const char *prefix, int id, const char *type, const char *name, int direction, int state, int avail_mode) {
- pa_logl(level, "%s device id(%d) type(%s) name (%s) direction(%d) state(%d) avail-mode(%d)",
- pa_strempty(prefix), id, pa_strnull(type), pa_strnull(name), direction, state, avail_mode);
+static inline void simple_device_dump(pa_log_level_t level, const char *prefix, int id, const char *type, const char *name, int direction, int state) {
+ pa_logl(level, "%s device id(%d) type(%s) name (%s) direction(%d) state(%d)",
+ pa_strempty(prefix), id, pa_strnull(type), pa_strnull(name), direction, state);
}
static void type_info_free_func(struct device_type_info *type_info) {
}
}
-static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type, const char *device_profile) {
+static struct device_type_info* _device_manager_get_type_info(pa_idxset *type_infos, const char *type) {
struct device_type_info *type_info;
uint32_t type_idx;
PA_IDXSET_FOREACH(type_info, type_infos, type_idx) {
- if (device_type_is_equal(type_info->type, type_info->profile, type, device_profile)) {
+ if (device_type_is_equal(type_info->type, type)) {
return type_info;
}
}
return NULL;
}
-static struct device_status_info* _device_status_new(const char *type, const char *profile,
+static struct device_status_info* _device_status_new(const char *type,
const char *name, const char *system_id) {
struct device_status_info *status_info;
status_info = (struct device_status_info *) pa_xmalloc0(sizeof(struct device_status_info));
status_info->type = pa_xstrdup(type);
- status_info->profile = pa_xstrdup(profile);
status_info->name = pa_xstrdup(name);
status_info->system_id = pa_xstrdup(system_id);
status_info->detected = DEVICE_DISCONNECTED;
return ;
pa_xfree(status_info->type);
- pa_xfree(status_info->profile);
pa_xfree(status_info->name);
pa_xfree(status_info->system_id);
pa_xfree(status_info);
}
static struct device_status_info* _get_device_status(pa_device_manager *manager, const char *type,
- const char *device_profile, const char *system_id) {
+ const char *system_id) {
struct device_status_info *status_info = NULL;
uint32_t status_idx;
pa_assert(manager->device_status);
PA_IDXSET_FOREACH(status_info, manager->device_status, status_idx) {
- if (device_type_is_equal(status_info->type, status_info->profile, type, device_profile)) {
+ if (device_type_is_equal(status_info->type, type)) {
if (device_type_is_avail_multi_device(type)) {
/* if system_id is null, just compare type */
if (system_id == NULL)
return params;
}
-static device_detected_type_t _device_get_detected(pa_device_manager *manager, const char *type, const char *device_profile,
+static device_detected_type_t _device_get_detected(pa_device_manager *manager, const char *type,
const char *system_id) {
struct device_status_info *status_info;
pa_assert(manager->device_status);
pa_assert(type);
- if (!device_type_is_need_detect(type, device_profile))
+ if (!device_type_is_need_detect(type))
return DEVICE_CONNECTED;
- status_info = _get_device_status(manager, type, device_profile, system_id);
+ status_info = _get_device_status(manager, type, system_id);
if (!status_info) {
- pa_log_info("No status info for type(%s) profile(%s) system_id(%s)",
- type, pa_strempty(device_profile), pa_strempty(system_id));
+ pa_log_info("No status info for type(%s) system_id(%s)",
+ type, pa_strempty(system_id));
return DEVICE_DISCONNECTED;
}
- pa_log_debug("Get device detected, type(%s) profile(%s) system_id(%s) : %s(%d)",
- type, pa_strempty(device_profile), pa_strempty(system_id),
+ pa_log_debug("Get device detected, type(%s) system_id(%s) : %s(%d)",
+ type, pa_strempty(system_id),
(status_info->detected & DEVICE_CONNECTED) ? "Connected" : "Disconnected", status_info->detected);
return status_info->detected;
}
-static void _device_set_detected(pa_device_manager *manager, const char *type, const char *device_profile,
+static void _device_set_detected(pa_device_manager *manager, const char *type,
const char *name, const char *system_id, device_detected_type_t detected_type) {
struct device_status_info *status_info;
pa_assert(manager->device_status);
pa_assert(type);
- if (!device_type_is_need_detect(type, device_profile))
+ if (!device_type_is_need_detect(type))
return ;
- pa_log_info("Set device detected, type(%s) profile(%s) system_id(%s) -> %s(%d)",
- type, pa_strempty(device_profile), pa_strempty(system_id),
+ pa_log_info("Set device detected, type(%s) system_id(%s) -> %s(%d)",
+ type, pa_strempty(system_id),
(detected_type & DEVICE_CONNECTED) ? "Connected" : "Disconnected", detected_type);
if (detected_type & DEVICE_CONNECTED) {
- status_info = _get_device_status(manager, type, device_profile, system_id);
+ status_info = _get_device_status(manager, type, system_id);
if (!status_info) {
- status_info = _device_status_new(type, device_profile, name, system_id);
+ status_info = _device_status_new(type, name, system_id);
pa_idxset_put(manager->device_status, status_info, NULL);
}
status_info->detected = detected_type;
} else {
- status_info = _get_device_status(manager, type, device_profile, system_id);
+ status_info = _get_device_status(manager, type, system_id);
if (status_info) {
pa_idxset_remove_by_data(manager->device_status, status_info, NULL);
_device_status_free(status_info);
pa_assert(type_info);
pa_assert(device_string);
- direction = device_type_get_static_direction(type_info->type, type_info->profile);
+ direction = device_type_get_static_direction(type_info->type);
if (direction == DM_DEVICE_DIRECTION_NONE) {
pa_log_debug("Not static direction");
return NULL;
}
if (!pcm_devices) {
- pa_log_warn("No %s pcm devices for %s %s", is_playback ? "playback" : "capture",
- type_info->type, pa_strempty(type_info->profile));
+ pa_log_warn("No %s pcm devices for %s", is_playback ? "playback" : "capture", type_info->type);
return NULL;
}
if (role) {
ctype = pa_xmalloc0(sizeof(struct composite_type));
ctype->type = type_info->type;
- ctype->profile = type_info->profile;
ctype->role = role;
pa_dynarray_append(ctypes, ctype);
}
if (pa_streq(type, DEVICE_TYPE_USB_AUDIO))
return pa_proplist_gets(prop, "udev.id");
- else if (pa_streq(type, DEVICE_TYPE_BT))
+ else if (pa_streq(type, DEVICE_TYPE_BT_A2DP))
return pa_proplist_gets(prop, "bluez.alias");
else
return NULL;
return NULL;
}
-static pa_sink* _device_manager_set_default_sink(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+static pa_sink* _core_get_sink(pa_core *core, const char *device_string, const char *params) {
+ uint32_t device_idx;
+ pa_sink *sink;
+
+ pa_assert(core);
+ pa_assert(device_string);
+
+ PA_IDXSET_FOREACH(sink, core->sinks, device_idx) {
+ if (pulse_device_is_monitor(PA_OBJECT(sink)))
+ continue;
+ if (pulse_device_same_device_string(PA_OBJECT(sink), device_string)) {
+ if (params == NULL)
+ return sink;
+ else if (pulse_device_params_is_equal(PA_OBJECT(sink), params))
+ return sink;
+ }
+ }
+
+ return NULL;
+}
+
+static pa_source* _core_get_source(pa_core *core, const char *device_string, const char *params) {
+ uint32_t device_idx;
+ pa_source *source;
+
+ pa_assert(core);
+ pa_assert(device_string);
+
+ PA_IDXSET_FOREACH(source, core->sources, device_idx) {
+ if (pulse_device_is_monitor(PA_OBJECT(source)))
+ continue;
+ if (pulse_device_same_device_string(PA_OBJECT(source), device_string)) {
+ if (params == NULL)
+ return source;
+ else if (pulse_device_params_is_equal(PA_OBJECT(source), params))
+ return source;
+ }
+ }
+
+ return NULL;
+}
+
+
+static void _fill_new_data_basic(pa_tz_device_new_data *data, const char *type,
+ dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
+ pa_assert(data);
+
+ pa_tz_device_new_data_set_type(data, type);
+ pa_tz_device_new_data_set_direction(data, direction);
+ pa_tz_device_new_data_set_use_internal_codec(data, use_internal_codec);
+}
+
+static int _fill_new_data_sinks(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
+ pa_sink *sink;
+ char *device_string, *role;
+ void *state;
+
+ pa_assert(data);
+ pa_assert(type_info);
+
+ if (type_info->playback_devices == NULL) {
+ pa_log_error("No playback devices for %s", type_info->type);
+ return -1;
+ }
+
+ PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
+ sink = _core_get_sink(dm->core, device_string, NULL);
+ if (sink)
+ pa_tz_device_new_data_add_sink(data, role, sink);
+ else
+ pa_log_error("Failed to get matching sink for %s %s", role, device_string);
+ }
+
+ return 0;
+}
+
+static int _fill_new_data_sources(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
+ pa_source *source;
+ char *device_string, *role;
+ void *state;
+
+ pa_assert(data);
+ pa_assert(type_info);
+
+ if (type_info->capture_devices == NULL) {
+ pa_log_error("No capture devices for %s", type_info->type);
+ return -1;
+ }
+
+ PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
+ source = _core_get_source(dm->core, device_string, NULL);
+ if (source)
+ pa_tz_device_new_data_add_source(data, role, source);
+ else
+ pa_log_error("Failed to get matching source for %s %s", role, device_string);
+ }
+
+ return 0;
+}
+
+static pa_sink* _device_manager_set_default_sink(pa_device_manager *dm, const char *type, const char *role) {
pa_tz_device *device;
pa_sink *sink;
return sink;
}
-static pa_source* _device_manager_set_default_source(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+static pa_source* _device_manager_set_default_source(pa_device_manager *dm, const char *type, const char *role) {
pa_tz_device *device;
pa_source *source;
if (is_loaded) {
pa_tz_device_new_data data;
- pa_tz_profile_new_data profile_data;
- /* Use profile_new_data, because BT is multi profile type */
- pa_tz_profile_new_data_init(&profile_data);
- pa_tz_profile_new_data_set_profile(&profile_data, DEVICE_PROFILE_BT_A2DP);
- pa_tz_profile_new_data_set_direction(&profile_data, direction);
- pa_tz_profile_new_data_set_use_internal_codec(&profile_data, false);
+ const char *name;
+ name = pulse_device_get_device_name(pdevice, DEVICE_TYPE_BT_A2DP);
+
+ pa_tz_device_new_data_init(&data, manager->device_list, manager->comm, manager->dbus_conn);
+ _fill_new_data_basic(&data, DEVICE_TYPE_BT_A2DP, direction, false, manager);
+ pa_tz_device_new_data_set_name(&data, name);
+ pa_tz_device_new_data_set_system_id(&data, system_id);
if (direction == DM_DEVICE_DIRECTION_OUT)
- pa_tz_profile_new_data_add_sink(&profile_data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice));
+ pa_tz_device_new_data_add_sink(&data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice));
else
- pa_tz_profile_new_data_add_source(&profile_data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice));
-
- device = _device_list_get_device(manager, DEVICE_TYPE_BT, system_id);
- /* Just add profile, if already exists */
- if (device) {
- dm_device_bt_sco_status_t sco_status;
- if (pa_tz_device_sco_get_status(device, &sco_status) < 0) {
- pa_log_error("Failed to get sco status");
- return ;
- }
- if (sco_status == DM_DEVICE_BT_SCO_STATUS_OPENED)
- pa_tz_device_add_profile(device, &profile_data, false);
- else
- pa_tz_device_add_profile(device, &profile_data, true);
- } else {
- /* Create new device with profile */
- const char *name;
- name = pulse_device_get_device_name(pdevice, DEVICE_TYPE_BT);
-
- pa_tz_device_new_data_init(&data, manager->device_list, manager->comm, manager->dbus_conn);
- pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_BT);
- pa_tz_device_new_data_set_name(&data, name);
- pa_tz_device_new_data_set_system_id(&data, system_id);
- pa_tz_device_new_data_add_profile(&data, &profile_data, true);
+ pa_tz_device_new_data_add_source(&data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice));
- pa_tz_device_new(&data);
- pa_tz_device_new_data_done(&data);
- }
- pa_tz_profile_new_data_done(&profile_data);
+ pa_tz_device_new(&data);
+ pa_tz_device_new_data_done(&data);
} else {
- if (!(device = _device_list_get_device(manager, DEVICE_TYPE_BT, system_id)))
+ if (!(device = _device_list_get_device(manager, DEVICE_TYPE_BT_A2DP, system_id)))
pa_log_warn("Can't get bt device for %s", system_id);
- else {
- if (pa_tz_device_get_profile_num(device) > 1)
- pa_tz_device_remove_profile(device, DEVICE_PROFILE_BT_A2DP);
- else
- pa_tz_device_free(device);
- }
+ else
+ pa_tz_device_free(device);
}
}
/* Put this pulse_device to already loaded devices */
for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
ctype = pa_dynarray_get(ctypes, i);
- pa_log_info("Found belongs type %s %s %s", ctype->type, pa_strempty(ctype->profile), ctype->role);
+ pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
if ((device = _device_list_get_device(manager, ctype->type, NULL))) {
pa_log_info("Add this pulse_device to device(%u)", pa_tz_device_get_id(device));
if (direction == DM_DEVICE_DIRECTION_OUT)
- pa_tz_device_profile_add_sink(device, ctype->profile, ctype->role, PA_SINK(pdevice));
+ pa_tz_device_add_sink(device, ctype->role, PA_SINK(pdevice));
else
- pa_tz_device_profile_add_source(device, ctype->profile, ctype->role, PA_SOURCE(pdevice));
+ pa_tz_device_add_source(device, ctype->role, PA_SOURCE(pdevice));
} else {
pa_log_info("No device for %s", ctype->type);
}
/* Remove this pulse_device from already loaded devices */
for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
ctype = pa_dynarray_get(ctypes, i);
- pa_log_info("Found belongs type %s %s %s", ctype->type, ctype->profile, ctype->role);
+ pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
if ((device = _device_list_get_device(manager, ctype->type, NULL))) {
pa_log_info("Remove this pulse_device from device(%u)", pa_tz_device_get_id(device));
if (direction == DM_DEVICE_DIRECTION_OUT)
return NULL;
}
-static pa_sink* _core_get_sink(pa_core *core, const char *device_string, const char *params) {
- uint32_t device_idx;
- pa_sink *sink;
-
- pa_assert(core);
- pa_assert(device_string);
-
- PA_IDXSET_FOREACH(sink, core->sinks, device_idx) {
- if (pulse_device_is_monitor(PA_OBJECT(sink)))
- continue;
- if (pulse_device_same_device_string(PA_OBJECT(sink), device_string)) {
- if (params == NULL)
- return sink;
- else if (pulse_device_params_is_equal(PA_OBJECT(sink), params))
- return sink;
- }
- }
-
- return NULL;
-}
-
-static pa_source* _core_get_source(pa_core *core, const char *device_string, const char *params) {
- uint32_t device_idx;
- pa_source *source;
-
- pa_assert(core);
- pa_assert(device_string);
-
- PA_IDXSET_FOREACH(source, core->sources, device_idx) {
- if (pulse_device_is_monitor(PA_OBJECT(source)))
- continue;
- if (pulse_device_same_device_string(PA_OBJECT(source), device_string)) {
- if (params == NULL)
- return source;
- else if (pulse_device_params_is_equal(PA_OBJECT(source), params))
- return source;
- }
- }
-
- return NULL;
-}
-
-
-static void _fill_new_data_basic(pa_tz_device_new_data *data, const char *type,
- dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
- pa_assert(data);
-
- pa_tz_device_new_data_set_type(data, type);
- pa_tz_device_new_data_set_direction(data, direction);
- pa_tz_device_new_data_set_use_internal_codec(data, use_internal_codec);
-}
-
-static void _fill_profile_new_data_basic(pa_tz_profile_new_data *profile_data,
- const char *profile, dm_device_direction_t direction, bool use_internal_codec, pa_device_manager *dm) {
- pa_assert(profile_data);
-
- pa_tz_profile_new_data_set_profile(profile_data, profile);
- pa_tz_profile_new_data_set_direction(profile_data, direction);
- pa_tz_profile_new_data_set_use_internal_codec(profile_data, use_internal_codec);
-}
-
-static int _fill_new_data_sinks(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
- pa_sink *sink;
- char *device_string, *role;
- void *state;
-
- pa_assert(data);
- pa_assert(type_info);
-
- if (type_info->playback_devices == NULL) {
- pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
- return -1;
- }
-
- PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
- sink = _core_get_sink(dm->core, device_string, NULL);
- if (sink)
- pa_tz_device_new_data_add_sink(data, role, sink);
- else
- pa_log_error("Failed to get matching sink for %s %s", role, device_string);
- }
-
- return 0;
-}
-
-static int _fill_new_data_sources(pa_tz_device_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
- pa_source *source;
- char *device_string, *role;
- void *state;
-
- pa_assert(data);
- pa_assert(type_info);
-
- if (type_info->capture_devices == NULL) {
- pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
- return -1;
- }
-
- PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
- source = _core_get_source(dm->core, device_string, NULL);
- if (source)
- pa_tz_device_new_data_add_source(data, role, source);
- else
- pa_log_error("Failed to get matching source for %s %s", role, device_string);
- }
-
- return 0;
-}
-
-static int _fill_profile_new_data_sinks(pa_tz_profile_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
- pa_sink *sink;
- char *device_string, *role;
- void *state;
-
- pa_assert(data);
- pa_assert(type_info);
-
- if (type_info->playback_devices == NULL) {
- pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
- return -1;
- }
-
- PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) {
- sink = _core_get_sink(dm->core, device_string, NULL);
- if (sink)
- pa_tz_profile_new_data_add_sink(data, role, sink);
- else
- pa_log_error("Failed to get matching sink for %s %s", role, device_string);
- }
-
- return 0;
-}
-
-static int _fill_profile_new_data_sources(pa_tz_profile_new_data *data, struct device_type_info *type_info, pa_device_manager *dm) {
- pa_source *source;
- char *device_string, *role;
- void *state;
-
- pa_assert(data);
- pa_assert(type_info);
-
- if (type_info->capture_devices == NULL) {
- pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
- return -1;
- }
-
- PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) {
- source = _core_get_source(dm->core, device_string, NULL);
- if (source)
- pa_tz_profile_new_data_add_source(data, role, source);
- else
- pa_log_error("Failed to get matching source for %s %s", role, device_string);
- }
-
- return 0;
-}
-
static int _load_type_devices(struct device_type_info *type_info, bool is_playback, pa_device_manager *dm) {
pa_hashmap *pcm_devices;
pa_idxset *file_infos;
pa_assert(dm);
pa_assert(type_info);
- pa_log_info("Load type devices : %s %s %s", type_info->type, pa_strempty(type_info->profile),
- is_playback ? "playback" : "capture");
+ pa_log_info("Load type devices : %s %s", type_info->type, is_playback ? "playback" : "capture");
if (is_playback) {
pcm_devices = type_info->playback_devices;
And if correnspondent sink/sources for device_type exist, should make device and notify it.
Use [device_type->roles] mappings in sink/source for find proper sink/source.
*/
-static void handle_device_connected(pa_device_manager *dm, const char *type, const char *device_profile,
+static void handle_device_connected(pa_device_manager *dm, const char *type,
const char *name, const char *system_id, device_detected_type_t detected_type) {
struct device_type_info *type_info;
- pa_tz_device *device;
pa_tz_device_new_data data;
pa_assert(dm);
pa_assert(dm->device_status);
pa_assert(dm->device_list);
- pa_log_info("Device connected, type(%s) profile(%s) name(%s) system_id(%s) detected_type(%d)",
- type, pa_strempty(device_profile), pa_strempty(name), pa_strempty(system_id), detected_type);
-
- type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile);
-
- if (device_type_is_equal(type, device_profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
- pa_tz_profile_new_data profile_data;
-
- /* Use profile_new_data, because BT is multi profile type */
- pa_tz_profile_new_data_init(&profile_data);
- _fill_profile_new_data_basic(&profile_data, DEVICE_PROFILE_BT_SCO,
- DM_DEVICE_DIRECTION_BOTH, true, dm);
-
- _fill_profile_new_data_sinks(&profile_data, type_info, dm);
- _fill_profile_new_data_sources(&profile_data, type_info, dm);
+ pa_log_info("Device connected, type(%s) name(%s) system_id(%s) detected_type(%d)",
+ type, pa_strempty(name), pa_strempty(system_id), detected_type);
- device = _device_list_get_device(dm, DEVICE_TYPE_BT, system_id);
- if (device) {
- /* Just add profile, if already exists */
- pa_tz_device_add_profile(device, &profile_data, false);
- } else {
- /* Create new device with profile */
-
- pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn);
- pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_BT);
- pa_tz_device_new_data_set_name(&data, name);
- pa_tz_device_new_data_set_system_id(&data, system_id);
- pa_tz_device_new_data_add_profile(&data, &profile_data, true);
+ type_info = _device_manager_get_type_info(dm->type_infos, type);
- pa_tz_device_new(&data);
- pa_tz_device_new_data_done(&data);
- }
- pa_tz_profile_new_data_done(&profile_data);
- } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+ if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+ pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn);
+ _fill_new_data_basic(&data, DEVICE_TYPE_BT_SCO, DM_DEVICE_DIRECTION_BOTH, true, dm);
+ _fill_new_data_sinks(&data, type_info, dm);
+ _fill_new_data_sources(&data, type_info, dm);
+ pa_tz_device_new_data_set_name(&data, name);
+ pa_tz_device_new_data_set_system_id(&data, system_id);
+ pa_tz_device_new(&data);
+ pa_tz_device_new_data_done(&data);
+ } else if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
dm_device_direction_t direction;
if (detected_type == DEVICE_CONNECTED_AUDIO_JACK_4P)
pa_tz_device_new(&data);
pa_tz_device_new_data_done(&data);
- } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_HDMI, NULL)) {
+ } else if (device_type_is_equal(type, DEVICE_TYPE_HDMI)) {
pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL);
_fill_new_data_basic(&data, DEVICE_TYPE_HDMI, DM_DEVICE_DIRECTION_OUT, true, dm);
_fill_new_data_sinks(&data, type_info, dm);
pa_tz_device_new(&data);
pa_tz_device_new_data_done(&data);
- } else if (device_type_is_equal(type, device_profile, DEVICE_TYPE_FORWARDING, NULL)) {
+ } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) {
_load_forwarding_device(dm);
} else {
dm_device_direction_t direction;
- direction = device_type_get_static_direction(type, device_profile);
+ direction = device_type_get_static_direction(type);
if (direction != DM_DEVICE_DIRECTION_NONE) {
pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL);
_fill_new_data_basic(&data, type, direction, true, dm);
First, update device-status hashmap.
And if there is device which has the device_type, remove it.
*/
-static int handle_device_disconnected(pa_device_manager *dm, const char *type, const char *device_profile, const char *system_id) {
+static int handle_device_disconnected(pa_device_manager *dm, const char *type, const char *system_id) {
pa_tz_device *device;
- uint32_t n_profile;
pa_assert(dm);
pa_assert(dm->device_status);
- pa_log_info("Device type(%s) profile(%s) system_id(%s) disconnected",
- type, pa_strempty(device_profile), pa_strempty(system_id));
+ pa_log_info("Device type(%s) system_id(%s) disconnected",
+ type, pa_strempty(system_id));
device = _device_list_get_device(dm, type, system_id);
if (!device) {
return -1;
}
- if ((n_profile = pa_tz_device_get_profile_num(device)) > 1)
- pa_tz_device_remove_profile(device, device_profile);
- else
- pa_tz_device_free(device);
+ pa_tz_device_free(device);
return 0;
}
struct device_type_info *type_info;
uint32_t type_idx;
device_detected_type_t detected_type = DEVICE_CONNECTED;
- const char *type, *profile;
+ const char *type;
pa_assert(dm);
PA_IDXSET_FOREACH(type_info, dm->type_infos, type_idx) {
type = type_info->type;
- profile = type_info->profile;
- pa_log_info("type_info : %s %s", type, pa_strempty(profile));
- detected_type = _device_get_detected(dm, type, profile, NULL);
+ pa_log_info("type_info : %s", type);
+ detected_type = _device_get_detected(dm, type, NULL);
if (detected_type == DEVICE_DISCONNECTED) {
pa_log_info("Not detected yet");
continue;
}
- if (device_type_is_equal(type, profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+ if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
if (detected_type == DEVICE_CONNECTED_AUDIO_JACK_4P) {
_load_type_devices(type_info, true, dm);
_load_type_devices(type_info, false, dm);
} else {
_load_type_devices(type_info, true, dm);
}
- handle_device_connected(dm, type, profile, NULL, NULL, detected_type);
- } else if (device_type_is_use_external_card(type, profile) == false) {
+ handle_device_connected(dm, type, NULL, NULL, detected_type);
+ } else if (device_type_is_use_external_card(type) == false) {
dm_device_direction_t direction;
- direction = device_type_get_static_direction(type, profile);
+ direction = device_type_get_static_direction(type);
if (direction == DM_DEVICE_DIRECTION_NONE) {
pa_log_warn("Wrong direction");
continue;
_load_type_devices(type_info, true, dm);
if (direction & DM_DEVICE_DIRECTION_IN)
_load_type_devices(type_info, false, dm);
- handle_device_connected(dm, type, profile, NULL, NULL, detected_type);
+ handle_device_connected(dm, type, NULL, NULL, detected_type);
} else {
pa_log_warn("Invalid case");
}
if ((device_o = json_object_array_get_idx(device_array_o, device_type_idx)) && json_object_is_type(device_o, json_type_object)) {
json_object *device_prop_o;
- const char *type = NULL, *device_profile = NULL;
+ const char *type = NULL;
type_info = pa_xmalloc0(sizeof(struct device_type_info));
if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_DEVICE_TYPE, &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
pa_log_error("Get device type failed");
goto fail;
}
- if (json_object_object_get_ex(device_o, "profile", &device_prop_o) && json_object_is_type(device_prop_o, json_type_string)) {
- device_profile = json_object_get_string(device_prop_o);
- pa_log_info("Profile - %s", device_profile);
- type_info->profile = device_profile;
- } else {
- pa_log_debug("no device-profile");
- }
if (json_object_object_get_ex(device_o, DEVICE_TYPE_PROP_PLAYBACK_DEVICES, &device_prop_o) && json_object_is_type(device_prop_o, json_type_object)) {
pa_log_info("Playback Devices");
/*
look detected status which is external value, make conversion to internal consistent value, and handle it
- device_type, device_profile : which type of device is detected
+ device_type, which type of device is detected
system_id : system_id among same device types for support multi-device
*/
static int handle_device_status_changed(pa_device_manager *dm, const char *type,
- const char *profile, const char *name, const char *system_id, device_detected_type_t detected) {
+ const char *name, const char *system_id, device_detected_type_t detected) {
pa_assert(dm);
pa_assert(device_type_is_valid(type));
- pa_log_info("Device Status Changed, type(%s) profile(%s) system_id(%s), detected_type(%d)",
- type, pa_strempty(profile), pa_strempty(system_id), detected);
+ pa_log_info("Device Status Changed, type(%s) system_id(%s), detected_type(%d)",
+ type, pa_strempty(system_id), detected);
- if (device_type_is_equal(type, profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
- _device_set_detected(dm, type, profile, name, system_id, detected);
+ if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+ _device_set_detected(dm, type, name, system_id, detected);
if (detected == DEVICE_DISCONNECTED)
- handle_device_disconnected(dm, type, profile, system_id);
+ handle_device_disconnected(dm, type, system_id);
else
- handle_device_connected(dm, type, profile, name, system_id, detected);
- } else if (device_type_is_need_detect(type, profile)) {
- _device_set_detected(dm, type, profile, name, system_id, detected);
+ handle_device_connected(dm, type, name, system_id, detected);
+ } else if (device_type_is_need_detect(type)) {
+ _device_set_detected(dm, type, name, system_id, detected);
if (detected == DEVICE_DISCONNECTED)
- handle_device_disconnected(dm, type, profile, system_id);
+ handle_device_disconnected(dm, type, system_id);
else
- handle_device_connected(dm, type, profile, name, system_id, detected);
+ handle_device_connected(dm, type, name, system_id, detected);
} else {
- pa_log_debug("No need to detect type %s %s", type, pa_strempty(profile));
+ pa_log_debug("No need to detect type %s", type);
}
return 0;
static void device_type_status_init(pa_device_manager *manager) {
struct device_type_info *type_info;
uint32_t type_idx;
- const char *type, *profile;
+ const char *type;
pa_assert(manager);
pa_assert(manager->type_infos);
PA_IDXSET_FOREACH(type_info, manager->type_infos, type_idx) {
type = type_info->type;
- profile = type_info->profile;
- if (device_type_is_equal(type, profile, DEVICE_TYPE_AUDIO_JACK, NULL)) {
+ if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
int earjack_status = 0;
if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status) < 0) {
pa_log_error("Get earjack status failed");
continue;
}
if (earjack_status == EARJACK_TYPE_SPK_ONLY)
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_3P);
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_3P);
else if (earjack_status == EARJACK_TYPE_SPK_WITH_MIC)
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_4P);
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED_AUDIO_JACK_4P);
else if (earjack_status == EARJACK_DISCONNECTED)
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
else
pa_log_warn("Unknown earjack status : %d", earjack_status);
- } else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO)) {
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
- } else if (device_type_is_equal(type, profile, DEVICE_TYPE_HDMI, NULL)) {
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_DISCONNECTED);
- } else if (device_type_is_equal(type, profile, DEVICE_TYPE_FORWARDING, NULL)) {
+ } else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) {
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
+ } else if (device_type_is_equal(type, DEVICE_TYPE_HDMI)) {
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED);
+ } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) {
int miracast_wfd_status = 0;
if (vconf_get_bool(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &miracast_wfd_status) < 0) {
pa_log_error("Get mirroring status failed");
continue;
}
if (miracast_wfd_status == FORWARDING_CONNECTED)
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED);
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
} else {
- _device_set_detected(manager, type, profile, NULL, NULL, DEVICE_CONNECTED);
+ _device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
}
}
return ;
#ifdef HAVE_DBUS
-static int _translate_external_value(const char *type, const char *profile, int value, device_detected_type_t *detected) {
+static int _translate_external_value(const char *type, int value, device_detected_type_t *detected) {
if (!type || !detected) {
pa_log_error("Invalid Parameter for translate");
return -1;
}
- if (device_type_is_equal(DEVICE_TYPE_AUDIO_JACK, NULL, type, profile)) {
+ if (device_type_is_equal(DEVICE_TYPE_AUDIO_JACK, type)) {
if (value == EARJACK_DISCONNECTED)
*detected = DEVICE_DISCONNECTED;
else if (value == EARJACK_TYPE_SPK_ONLY)
*detected = DEVICE_CONNECTED_AUDIO_JACK_4P;
else
return -1;
- } else if (device_type_is_equal(DEVICE_TYPE_HDMI, NULL, type, profile)) {
+ } else if (device_type_is_equal(DEVICE_TYPE_HDMI, type)) {
if (value == HDMI_AUDIO_DISCONNECTED)
*detected = DEVICE_DISCONNECTED;
else if (value == HDMI_AUDIO_AVAILABLE)
*detected = DEVICE_CONNECTED;
else
return -1;
- } else if (device_type_is_equal(DEVICE_TYPE_FORWARDING, NULL, type, profile)) {
+ } else if (device_type_is_equal(DEVICE_TYPE_FORWARDING, type)) {
if (value == FORWARDING_DISCONNECTED)
*detected = DEVICE_DISCONNECTED;
else if (value == FORWARDING_CONNECTED)
*detected = DEVICE_CONNECTED;
else
return -1;
- } else if (device_type_is_equal(DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, type, profile)) {
+ } else if (device_type_is_equal(DEVICE_TYPE_BT_SCO, type)) {
if (value == BT_SCO_DISCONNECTED)
*detected = DEVICE_DISCONNECTED;
else if (value == BT_SCO_CONNECTED)
if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
goto fail;
} else {
- if (_translate_external_value(DEVICE_TYPE_AUDIO_JACK, NULL, status, &detected) < 0) {
+ if (_translate_external_value(DEVICE_TYPE_AUDIO_JACK, status, &detected) < 0) {
pa_log_warn("failed to translate audio-jack detected value");
goto fail;
}
- handle_device_status_changed(dm, DEVICE_TYPE_AUDIO_JACK, NULL, NULL, NULL, detected);
+ handle_device_status_changed(dm, DEVICE_TYPE_AUDIO_JACK, NULL, NULL, detected);
}
} else if (dbus_message_is_signal(s, DBUS_INTERFACE_DEVICED_SYSNOTI, "ChangedHDMIAudio")) {
if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
goto fail;
} else {
- if (_translate_external_value(DEVICE_TYPE_HDMI, NULL, status, &detected) < 0) {
+ if (_translate_external_value(DEVICE_TYPE_HDMI, status, &detected) < 0) {
pa_log_warn("failed to translate HDMI detected value");
goto fail;
}
- handle_device_status_changed(dm, DEVICE_TYPE_HDMI, NULL, NULL, NULL, detected);
+ handle_device_status_changed(dm, DEVICE_TYPE_HDMI, NULL, NULL, detected);
}
} else if (dbus_message_is_signal(s, DBUS_INTERFACE_MIRRORING_SERVER, "miracast_wfd_source_status_changed")) {
if (!dbus_message_get_args(s, NULL, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
goto fail;
} else {
- if (_translate_external_value(DEVICE_TYPE_FORWARDING, NULL, status, &detected) < 0) {
+ if (_translate_external_value(DEVICE_TYPE_FORWARDING, status, &detected) < 0) {
pa_log_warn("failed to translate forwarding detected value");
goto fail;
}
- handle_device_status_changed(dm, DEVICE_TYPE_FORWARDING, NULL, NULL, NULL, detected);
+ handle_device_status_changed(dm, DEVICE_TYPE_FORWARDING, NULL, NULL, detected);
}
} else if (dbus_message_is_signal(s, DBUS_INTERFACE_BLUEZ_HEADSET, "PropertyChanged")) {
DBusMessageIter msg_iter, variant_iter;
} else {
status = BT_SCO_DISCONNECTED;
}
- if (_translate_external_value(DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO, status, &detected) < 0) {
+ if (_translate_external_value(DEVICE_TYPE_BT_SCO, status, &detected) < 0) {
pa_log_warn("failed to translate bt-sco detected value");
goto fail;
}
- handle_device_status_changed(dm, DEVICE_TYPE_BT, DEVICE_PROFILE_BT_SCO,
+ handle_device_status_changed(dm, DEVICE_TYPE_BT_SCO,
name, dbus_message_get_path(s), detected);
}
}
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_connection_changed_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, avail_mode;
+ dbus_int32_t device_id, direction;
char *type, *name;
pa_assert(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);
- simple_device_dump(PA_LOG_INFO, connected ? "[Connected]" : "[Disconnected]", device_id, type, name, direction, compound_state, avail_mode);
+ simple_device_dump(PA_LOG_INFO, connected ? "[Connected]" : "[Disconnected]", device_id, type, name, direction, compound_state);
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_BOOLEAN, &_connected);
DBusMessage *signal_msg;
DBusMessageIter msg_iter, device_iter;
dm_device_state_t compound_state;
- dbus_int32_t device_id, direction, avail_mode;
+ dbus_int32_t device_id, direction;
char *type, *name;
const char *changed_prefix[] = {"[State Changed]", "[Direction Changed]", "[Avail-Mode Changed]"};
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);
- simple_device_dump(PA_LOG_DEBUG, changed_prefix[changed_type], device_id, type, name, direction, compound_state, avail_mode);
+ simple_device_dump(PA_LOG_DEBUG, changed_prefix[changed_type], device_id, type, name, direction, compound_state);
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);
pa_tz_device *device;
dm_device_state_t compound_state;
uint32_t device_idx;
- dbus_int32_t device_id, direction, avail_mode;
+ dbus_int32_t device_id, direction;
int mask;
char *type, *name;
pa_log_info("Get connected device list (mask : %d)", mask);
dbus_message_iter_init_append(reply, &msg_iter);
- pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiiis)", &array_iter));
+ pa_assert_se(dbus_message_iter_open_container(&msg_iter, DBUS_TYPE_ARRAY, "(isiis)", &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_is_match_with_mask(device, mask)) {
device_id = (dbus_int32_t)pa_tz_device_get_id(device);
- simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, compound_state, avail_mode);
+ simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, compound_state);
pa_assert_se(dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &device_iter));
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(&array_iter, &device_iter));
} else {
- simple_device_dump(PA_LOG_INFO, "[UNMATCH]", device_id, type, name, direction, compound_state, avail_mode);
+ simple_device_dump(PA_LOG_INFO, "[UNMATCH]", device_id, type, name, direction, compound_state);
}
}
pa_assert_se((reply = dbus_message_new_method_return(msg)));
/* FIXME : Give system_id for multi device */
- if ((device = _device_list_get_device(dm, DEVICE_TYPE_BT, NULL)) != NULL) {
- if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP)) {
- is_bt_on = true;
- bt_name = pa_tz_device_get_name(device);
- }
+ if ((device = _device_list_get_device(dm, DEVICE_TYPE_BT_A2DP, NULL)) != NULL) {
+ is_bt_on = true;
+ bt_name = pa_tz_device_get_name(device);
}
pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &is_bt_on,
static void handle_load_sink(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_device_manager *dm;
- char *type, *device_profile, *role;
+ char *type, *role;
DBusMessage *reply = NULL;
pa_assert_se((reply = dbus_message_new_method_return(msg)));
dm = (pa_device_manager *) userdata;
pa_assert_se(dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &device_profile,
DBUS_TYPE_STRING, &role,
DBUS_TYPE_INVALID));
- if (pa_streq(device_profile, "none"))
- device_profile = NULL;
- pa_device_manager_load_sink(dm, type, device_profile, role);
+ pa_device_manager_load_sink(dm, type, role);
pa_assert_se(dbus_connection_send(conn, reply, NULL));
dbus_message_unref(reply);
}
static void handle_test_device_status_change(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_device_manager *dm = (pa_device_manager *)userdata;
- char *type, *device_profile;
+ char *type;
dbus_int32_t status;
DBusMessage *reply = NULL;
DBusError error;
dbus_error_init(&error);
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &type,
- DBUS_TYPE_STRING, &device_profile,
DBUS_TYPE_INT32, &status,
DBUS_TYPE_INVALID)) {
pa_log_error("failed to get dbus args : %s", error.message);
dbus_error_free(&error);
}
- pa_log_debug("handle_test_device_status_change, type:%s, profile:%s, status:%d", type, device_profile, status);
- if (pa_streq(device_profile, "none"))
- device_profile = NULL;
+ pa_log_debug("handle_test_device_status_change, type:%s, status:%d", type, status);
- handle_device_status_changed(dm, type, device_profile, NULL, NULL, status);
+ handle_device_status_changed(dm, type, NULL, NULL, status);
pa_assert_se(dbus_connection_send(conn, reply, NULL));
dbus_message_unref(reply);
}
pa_log_warn("There is no forwarding device");
}
-int pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+int pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const char *role) {
const char *device_string, *params;
struct device_type_info *type_info;
struct device_file_info *file_info;
pa_assert(dm);
pa_assert(dm->device_list);
- pa_log_info("Load Sink for '%s.%s.%s'", type, device_profile, role);
+ pa_log_info("Load Sink for '%s.%s'", type, role);
PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
if (pa_streq(type, pa_tz_device_get_type(device))) {
- if (pa_tz_device_profile_get_sink(device, device_profile, role) == NULL) {
- pa_log_warn("Proper sink for '%s.%s.%s' already loaded", type, device_profile, role);
+ if (pa_tz_device_get_sink(device, role) == NULL) {
+ pa_log_warn("Proper sink for '%s.%s' already loaded", type, role);
return -1;
}
}
}
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
pa_log_error("No type map for %s", type);
return -1;
}
if (type_info->playback_devices == NULL) {
- pa_log_error("No playback devices for %s %s", type_info->type, pa_strempty(type_info->profile));
+ pa_log_error("No playback devices for %s", type_info->type);
goto fail;
}
if (!(device_string = pa_hashmap_get(type_info->playback_devices, role))) {
- pa_log_error("No device-string for '%s.%s.%s'", type, device_profile, role);
+ pa_log_error("No device-string for '%s.%s'", type, role);
goto fail;
}
return -1;
}
-int pa_device_manager_load_source(pa_device_manager *dm, const char *type, const char *device_profile, const char *role) {
+int pa_device_manager_load_source(pa_device_manager *dm, const char *type, const char *role) {
const char *device_string, *params;
struct device_type_info *type_info;
struct device_file_info *file_info;
pa_assert(dm);
- pa_log_info("Load Source for '%s.%s.%s'", type, device_profile, role);
+ pa_log_info("Load Source for '%s.%s'", type, role);
PA_IDXSET_FOREACH(device, dm->device_list, device_idx) {
if (pa_streq(type, pa_tz_device_get_type(device))) {
- if (pa_tz_device_profile_get_source(device, device_profile, role) == NULL) {
- pa_log_warn("Proper source for '%s.%s.%s' already loaded", type, device_profile, role);
+ if (pa_tz_device_get_source(device, role) == NULL) {
+ pa_log_warn("Proper source for '%s.%s' already loaded", type, role);
return -1;
}
}
}
- if (!(type_info = _device_manager_get_type_info(dm->type_infos, type, device_profile))) {
+ if (!(type_info = _device_manager_get_type_info(dm->type_infos, type))) {
pa_log_error("No type map for %s", type);
return -1;
}
if (type_info->capture_devices == NULL) {
- pa_log_error("No capture devices for %s %s", type_info->type, pa_strempty(type_info->profile));
+ pa_log_error("No capture devices for %s", type_info->type);
goto fail;
}
if (!(device_string = pa_hashmap_get(type_info->capture_devices, role))) {
- pa_log_error("No device-string for '%s.%s.%s'", type, device_profile, role);
+ pa_log_error("No device-string for '%s.%s'", type, role);
goto fail;
}
return PA_HOOK_OK;
}
-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;
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_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())) {
}
/* Just for convenience when test*/
- if (!_device_manager_set_default_sink(dm, DEVICE_TYPE_SPEAKER, NULL, "normal")) {
+ if (!_device_manager_set_default_sink(dm, DEVICE_TYPE_SPEAKER, "normal")) {
pa_log_warn("Set default sink with speaker(normal) failed");
}
- if (!_device_manager_set_default_source(dm, DEVICE_TYPE_MIC, NULL, "normal")) {
+ if (!_device_manager_set_default_source(dm, DEVICE_TYPE_MIC, "normal")) {
pa_log_warn("Set default source with mic(normal) failed");
}
if (dm->comm_hook_device_connection_changed_slot)
pa_hook_slot_free(dm->comm_hook_device_connection_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)
void pa_device_manager_unload_forwarding(pa_device_manager *dm);
/* load pulse device */
-int pa_device_manager_load_sink(pa_device_manager *dm, const char *device_type, const char *device_profile, const char *role);
-int pa_device_manager_load_source(pa_device_manager *dm, const char *device_type, const char *device_profile, const char *role);
+int pa_device_manager_load_sink(pa_device_manager *dm, const char *device_type, const char *role);
+int pa_device_manager_load_source(pa_device_manager *dm, const char *device_type, const char *role);
#endif
DEVICE_BUILTIN_RECEIVER,
DEVICE_BUILTIN_MIC,
DEVICE_AUDIO_JACK,
- DEVICE_BT,
+ DEVICE_BT_A2DP,
+ DEVICE_BT_SCO,
DEVICE_HDMI,
DEVICE_FORWARDING,
DEVICE_USB_AUDIO,
return DEVICE_BUILTIN_MIC;
else if (pa_streq(device, DEVICE_TYPE_AUDIO_JACK))
return DEVICE_AUDIO_JACK;
- else if (pa_streq(device, DEVICE_TYPE_BT))
- return DEVICE_BT;
+ else if (pa_streq(device, DEVICE_TYPE_BT_A2DP))
+ return DEVICE_BT_A2DP;
+ else if (pa_streq(device, DEVICE_TYPE_BT_SCO))
+ return DEVICE_BT_SCO;
else if (pa_streq(device, DEVICE_TYPE_HDMI))
return DEVICE_HDMI;
else if (pa_streq(device, DEVICE_TYPE_FORWARDING))
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_profile_changed_slot;
pa_hook_slot *comm_hook_update_info_slot;
} communicator;
device_list = pa_device_manager_get_device_list(dm);
PA_IDXSET_FOREACH(device, device_list, device_idx) {
- if (pa_streq(device->type, DEVICE_TYPE_BT)) {
- /* FIXME : not works */
- if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_SCO)) {
- return device;
- }
+ if (pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
+ return device;
}
}
return NULL;
return -1;
}
- if (sco_status == DM_DEVICE_BT_SCO_STATUS_DISCONNECTED) {
- pa_log_info("BT SCO is not available for this BT device");
- return 0;
- }
if (open) {
if (sco_status == DM_DEVICE_BT_SCO_STATUS_CONNECTED) {
if (pa_tz_device_sco_open(bt_device) < 0) {
if (pa_streq(device_type, DEVICE_TYPE_FORWARDING))
return true;
- if (pa_streq(device_type, DEVICE_TYPE_BT))
+ if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
+ return true;
+
+ if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
return true;
/* get sound profile */
uint32_t dm_device_id = 0;
const char *device_type = NULL;
const char *dm_device_type = NULL;
- const char *dm_device_subtype = NULL;
dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
pa_tz_device *device = NULL;
pa_tz_device *latest_device = NULL;
continue;
PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
dm_device_id = pa_tz_device_get_id(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u]",
- dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id);
+ pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u]",
+ dm_device_type, dm_device_direction, dm_device_id);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
is_found = true;
pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
continue;
PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
dm_device_id = pa_tz_device_get_id(device);
creation_time = pa_tz_device_get_creation_time(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u], creation_time[%llu]",
- dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id, creation_time);
+ pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]",
+ dm_device_type, dm_device_direction, dm_device_id, creation_time);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
if (!latest_device || (latest_creation_time <= creation_time)) {
latest_device = device;
PA_IDXSET_FOREACH(device_id, data->idx_manual_devices, m_idx) {
if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], device id[%u]",
- dm_device_type, dm_device_subtype, dm_device_direction, *device_id);
+ pa_log_debug(" -- type[%-16s], direction[0x%x], device id[%u]",
+ dm_device_type, dm_device_direction, *device_id);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction);
if (data->stream_type == STREAM_SINK_INPUT) {
PA_IDXSET_FOREACH(device_id, data->idx_manual_devices, m_idx) {
if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], device id[%u]",
- dm_device_type, dm_device_subtype, dm_device_direction, *device_id);
+ pa_log_debug(" -- type[%-16s], direction[0x%x], device id[%u]",
+ dm_device_type, dm_device_direction, *device_id);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction);
/* currently, we support two sinks for combining */
pa_tz_device *_device = NULL;
pa_tz_device *latest_device = NULL;
const char *dm_device_type = NULL;
- const char *dm_device_subtype = NULL;
dm_device_state_t dm_device_state = DM_DEVICE_STATE_DEACTIVATED;
dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
io_direction_t hal_direction;
continue;
PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
dm_device_id = pa_tz_device_get_id(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u]",
- dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id);
+ pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u]",
+ dm_device_type, dm_device_direction, dm_device_id);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
use_internal_codec = pa_tz_device_is_use_internal_codec(device);
continue;
PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
dm_device_type = pa_tz_device_get_type(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
dm_device_direction = pa_tz_device_get_direction(device);
dm_device_id = pa_tz_device_get_id(device);
creation_time = pa_tz_device_get_creation_time(device);
- pa_log_debug(" -- type[%-16s], subtype[%-5s], direction[0x%x], id[%u], creation_time[%llu]",
- dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id, creation_time);
- if (pa_streq(device->type, DEVICE_TYPE_BT) && !pa_tz_device_have_profile(device, "a2dp"))
+ pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]",
+ dm_device_type, dm_device_direction, dm_device_id, creation_time);
+ if (pa_streq(device->type, DEVICE_TYPE_BT_A2DP))
continue;
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
if (!latest_device || (latest_creation_time <= creation_time)) {
if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
/* FIXME : This is temparary code, until App could give
* proper BT-SCO device for call-voice */
- if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT)) {
+ if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT_A2DP)) {
pa_tz_device *sco_device;
if ((sco_device = _get_sco_connected_device(u->device_manager)) == NULL) {
pa_log_error(" ** could not find BT SCO");
dm_device_type = pa_tz_device_get_type(device);
if (pa_streq(device_type, dm_device_type)) {
dm_device_direction = pa_tz_device_get_direction(device);
- dm_device_subtype = pa_tz_device_get_profile(device);
- pa_log_debug(" ** found a matched device: type[%-16s], subtype[%-5s], direction[0x%x]",
- dm_device_type, dm_device_subtype, dm_device_direction);
+ pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]",
+ dm_device_type, dm_device_direction);
/* Check for BT SCO in case of call routing */
- if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT)) {
+ if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
/* update BT SCO: open */
if (update_bt_sco_state(u->device_manager, true)) {
pa_log_error(" ** could not open BT SCO");
return PA_HOOK_OK;
}
-/* Update connected device list when a device profile has been changed */
-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;
-
- pa_assert(c);
- pa_assert(conn);
- pa_assert(u);
-
- device_direction = pa_tz_device_get_direction(conn->device);
-
- 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 == 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. */
- ptr_in = &cached_connected_devices[convert_device_type_str(DEVICE_TYPE_BT)][CACHED_DEVICE_DIRECTION_IN];
- ptr_out = &cached_connected_devices[convert_device_type_str(DEVICE_TYPE_BT)][CACHED_DEVICE_DIRECTION_OUT];
- *ptr_in = *ptr_out = 0;
- if (device_direction & DM_DEVICE_DIRECTION_IN)
- *ptr_in = 1;
- if (device_direction & DM_DEVICE_DIRECTION_OUT)
- *ptr_out = 1;
- dump_connected_devices();
- }
-
- return PA_HOOK_OK;
-}
-
int pa__init(pa_module *m)
{
pa_modargs *ma = NULL;
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_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);
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_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);
struct {
pa_communicator *comm;
pa_hook_slot *comm_hook_device_connection_changed_slot;
- pa_hook_slot *comm_hook_device_profile_changed_slot;
pa_hook_slot *comm_hook_event_fully_handled_slot;
} comm;
};
}
} else if (!is_connected) {
/* DISCONNECTED: find a connected device that has the next priority */
- if ((sink && (sink == ((pa_sink_input*)s)->sink)) ||
- /* FIX ME: Although A2DP of BT device is off and it changes to SCO, sink from the device should be same as BT sink(for A2DP).
- * Because it does not work like that, new condition is added to avoid it temporarily. */
- (pa_safe_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq(pa_tz_device_get_profile(device), "sco"))) {
+ if ((sink && (sink == ((pa_sink_input*)s)->sink))) {
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
if (next_device) {
if ((next_sink = pa_tz_device_get_sink(next_device, DEVICE_ROLE_NORMAL))) {
return PA_HOOK_OK;
}
-/* Update connected device list when a device profile has been changed */
-static pa_hook_result_t device_profile_changed_hook_cb(pa_core *c, pa_tz_device_hook_data_for_profile_changed *conn, pa_stream_manager *m) {
- dm_device_direction_t device_direction = DM_DEVICE_DIRECTION_OUT;
- bool use_internal_codec = false;
- bool bt_sink_available = false;
-
- pa_assert(c);
- pa_assert(conn);
- pa_assert(m);
-
- device_direction = pa_tz_device_get_direction(conn->device);
- use_internal_codec = pa_tz_device_is_use_internal_codec(conn->device);
-
- pa_log_info("[SM][CONN] device_profile_changed_hook_cb is called. conn(%p), changed(%d), device(%p), direction(0x%x), use_internal_codec(%d)",
- conn, conn->changed, conn->device, device_direction, use_internal_codec);
-
- if (conn->changed == PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED) {
- if (pa_streq(pa_tz_device_get_type(conn->device), DEVICE_TYPE_BT)) {
- pa_log_info("[SM][CONN] BT: active profile changed to [%s]", pa_tz_device_get_profile(conn->device));
- if (use_internal_codec)
- bt_sink_available = false; /* already bt device is connected and A2DP is newly deactivated, now SCO is only activated */
- else
- bt_sink_available = true; /* already bt device is connected and A2DP is newly activated */
- }
- if (device_direction & DM_DEVICE_DIRECTION_OUT) {
- update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO, m->core->sink_inputs,
- STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
- update_sink_or_source_as_device_change(STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED, m->core->sink_inputs,
- STREAM_SINK_INPUT, conn->device, bt_sink_available, m);
- }
- }
-
- return PA_HOOK_OK;
-}
-
static void subscribe_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, pa_stream_manager *m) {
pa_client *client = NULL;
stream_parent *sp = NULL;
m->comm.comm = pa_communicator_get(c);
m->comm.comm_hook_device_connection_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED),
PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_connection_changed_hook_cb, m);
- m->comm.comm_hook_device_profile_changed_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_DEVICE_PROFILE_CHANGED),
- PA_HOOK_EARLY + 10, (pa_hook_cb_t)device_profile_changed_hook_cb, m);
m->comm.comm_hook_event_fully_handled_slot = pa_hook_connect(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_EVENT_FULLY_HANDLED),
PA_HOOK_EARLY + 10, (pa_hook_cb_t)event_fully_handled_hook_cb, m);
return false;
}
-bool device_profile_is_equal(const char *device_profile1, const char *device_profile2) {
- return pa_safe_streq2(device_profile1, device_profile2);
-}
-
-bool device_type_is_equal(const char *device_type1, const char *device_profile1, const char *device_type2, const char *device_profile2) {
+bool device_type_is_equal(const char *device_type1, const char *device_type2) {
pa_assert(device_type1);
pa_assert(device_type2);
- if (pa_streq(device_type1, device_type2))
- return device_profile_is_equal(device_profile1, device_profile2);
- else
- return false;
+ return pa_streq(device_type1, device_type2);
}
bool device_type_is_builtin(const char *device_type) {
return true;
else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK))
return true;
- else if (pa_streq(device_type, DEVICE_TYPE_BT))
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
+ return true;
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
return true;
else if (pa_streq(device_type, DEVICE_TYPE_HDMI))
return true;
return false;
}
-bool device_type_is_use_external_card(const char *device_type, const char *profile) {
+bool device_type_is_use_external_card(const char *device_type) {
if (!device_type)
return false;
else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO))
return true;
- else if ((pa_streq(device_type, DEVICE_TYPE_BT)) &&
- profile && pa_streq(profile, DEVICE_PROFILE_BT_A2DP))
- return true;
- else
- return false;
-}
-
-bool device_type_is_multi_profile(const char *device_type) {
- if (!device_type)
- return false;
- else if (pa_streq(device_type, DEVICE_TYPE_BT))
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
return true;
else
return false;
bool device_type_is_avail_multi_device(const char *device_type) {
if (!device_type)
return false;
- else if (pa_streq(device_type, DEVICE_TYPE_BT))
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
+ return true;
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
return true;
else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO))
return true;
return false;
}
-bool device_type_is_need_detect(const char *type, const char *profile) {
+bool device_type_is_need_detect(const char *type) {
if (!type)
return false;
else if (pa_streq(type, DEVICE_TYPE_AUDIO_JACK))
return true;
else if (pa_streq(type, DEVICE_TYPE_FORWARDING))
return true;
- else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT ,DEVICE_PROFILE_BT_SCO))
+ else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO))
return true;
else
return false;
* and other type(ex.audio-jack)'s direction varies with detected type,
* and the other types(ex. bt-a2dp, usb-audio)'s direction is decided with
* sink/source */
-dm_device_direction_t device_type_get_static_direction(const char *type, const char *profile) {
+dm_device_direction_t device_type_get_static_direction(const char *type) {
if (!type)
return DM_DEVICE_DIRECTION_NONE;
else if (pa_streq(type, DEVICE_TYPE_SPEAKER))
return DM_DEVICE_DIRECTION_OUT;
else if (pa_streq(type, DEVICE_TYPE_MIC))
return DM_DEVICE_DIRECTION_IN;
- else if (device_type_is_equal(type, profile, DEVICE_TYPE_BT ,DEVICE_PROFILE_BT_SCO))
+ else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO))
return DM_DEVICE_DIRECTION_BOTH;
else if (pa_streq(type, DEVICE_TYPE_HDMI))
return DM_DEVICE_DIRECTION_OUT;
/* Check whether 'direction' is valid for 'device_type'
* This is static device-type availability, not for runtime checking */
-bool device_type_is_valid_direction(const char *device_type, const char *device_profile, dm_device_direction_t direction) {
+bool device_type_is_valid_direction(const char *device_type, dm_device_direction_t direction) {
if (!device_type || direction == DM_DEVICE_DIRECTION_NONE)
return false;
return direction == DM_DEVICE_DIRECTION_IN;
else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK))
return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_BOTH;
- else if (pa_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq2(device_profile, DEVICE_PROFILE_BT_SCO))
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO))
return direction == DM_DEVICE_DIRECTION_BOTH;
- else if (pa_streq(device_type, DEVICE_TYPE_BT) && pa_safe_streq2(device_profile, DEVICE_PROFILE_BT_A2DP))
+ else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP))
return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_IN;
else if (pa_streq(device_type, DEVICE_TYPE_HDMI))
return direction == DM_DEVICE_DIRECTION_OUT;
return -1;
}
}
-
-int get_profile_priority(const char *device_profile) {
- if (!device_profile) {
- return 0;
- } else if (pa_streq(device_profile, DEVICE_PROFILE_BT_A2DP)) {
- return 1;
- } else if (pa_streq(device_profile, DEVICE_PROFILE_BT_SCO)) {
- return 2;
- } else {
- return -1;
- }
-}
-
-int compare_profile_priority(const char *device_profile1, const char *device_profile2) {
- int priority1, priority2;
-
- priority1 = get_profile_priority(device_profile1);
- priority2 = get_profile_priority(device_profile2);
-
- if (priority1 > priority2) {
- return 1;
- } else if (priority1 == priority2) {
- return 0;
- } else {
- return -1;
- }
-}
-
#define DEVICE_TYPE_RECEIVER "builtin-receiver"
#define DEVICE_TYPE_MIC "builtin-mic"
#define DEVICE_TYPE_AUDIO_JACK "audio-jack"
-#define DEVICE_TYPE_BT "bt"
+#define DEVICE_TYPE_BT_A2DP "bt-a2dp" /* match for SOUND_DEVICE_BLUETOOTH_MEDIA */
+#define DEVICE_TYPE_BT_SCO "bt-sco" /* match for SOUND_DEVICE_BLUETOOTH_CALL */
#define DEVICE_TYPE_HDMI "hdmi"
#define DEVICE_TYPE_FORWARDING "forwarding"
#define DEVICE_TYPE_USB_AUDIO "usb-audio"
#define DEVICE_TYPE_NONE "none"
-#define PROFILE_NUM_MAX 2
-#define DEVICE_PROFILE_BT_SCO "sco"
-#define DEVICE_PROFILE_BT_A2DP "a2dp"
-
#define DEVICE_ROLE_NORMAL "normal"
#define DEVICE_ROLE_CALL_VOICE "call-voice"
#define DEVICE_ROLE_CALL_VIDEO "call-video"
} dm_device_state_t;
typedef enum dm_device_bt_sco_status_type {
- DM_DEVICE_BT_SCO_STATUS_DISCONNECTED = 0,
DM_DEVICE_BT_SCO_STATUS_CONNECTED,
DM_DEVICE_BT_SCO_STATUS_OPENED
} dm_device_bt_sco_status_t;
for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)))
bool device_type_is_builtin(const char *device_type);
-bool device_type_is_use_external_card(const char *device_type, const char *device_profile);
+bool device_type_is_use_external_card(const char *device_type);
bool device_type_is_valid(const char *device_type);
-bool device_type_is_valid_direction(const char *device_type, const char *device_profile, dm_device_direction_t direction);
-bool device_type_is_multi_profile(const char *device_type);
+bool device_type_is_valid_direction(const char *device_type, dm_device_direction_t direction);
bool device_type_is_avail_multi_device(const char *device_type);
-bool device_type_is_need_detect(const char *type, const char *profile);
-dm_device_direction_t device_type_get_static_direction(const char *type, const char *profile);
+bool device_type_is_need_detect(const char *type);
+dm_device_direction_t device_type_get_static_direction(const char *type);
const char* device_direction_to_string(dm_device_direction_t direction);
bool device_role_is_valid(const char *device_role);
dm_device_direction_t device_direction_to_int(const char *device_direction);
-bool device_profile_is_equal(const char *device_profile1, const char *device_profile2);
-bool device_type_is_equal(const char *device_type1, const char *device_profile1, const char *device_type2, const char *device_profile2);
+bool device_type_is_equal(const char *device_type1, const char *device_type2);
#endif
#define BT_CVSD_CODEC_ID 1 // narrow-band
#define BT_MSBC_CODEC_ID 2 // wide-band
-#define COMPOUND_STATE(d) (((pa_tz_profile*)d)->playback_state | ((pa_tz_profile*)d)->capture_state)
+#define COMPOUND_STATE(d) (((pa_tz_device*)d)->playback_state | ((pa_tz_device*)d)->capture_state)
int device_id_max_g = 1;
uint32_t event_id_max_g = 1;
return pa_strbuf_tostring_free(buf);
}
-/* Returned string must be freed */
-static char* get_device_profile_info_str(pa_tz_profile *profile) {
+static char* _device_get_info_str(pa_tz_device *device) {
pa_strbuf *buf;
char *playback_str, *capture_str;
- if (!profile)
+
+ if (!device)
return NULL;
buf = pa_strbuf_new();
- pa_strbuf_printf(buf, " Profile : %s\n", pa_strna(profile->profile));
- pa_strbuf_printf(buf, " Direction : %s\n", device_direction_to_string(profile->direction));
- pa_strbuf_printf(buf, " Is activated : %s\n", pa_yes_no(COMPOUND_STATE(profile) == DM_DEVICE_STATE_ACTIVATED));
- pa_strbuf_printf(buf, " Internal : %s\n", pa_yes_no(profile->use_internal_codec));
- if (profile->profile && pa_streq(profile->profile, DEVICE_PROFILE_BT_SCO))
- pa_strbuf_printf(buf, " SCO opened : %s\n", pa_yes_no(profile->sco_opened));
- playback_str = get_playback_list_str(profile->playback_devices);
- capture_str = get_capture_list_str(profile->capture_devices);
+ pa_strbuf_printf(buf, "[Device #%u]\n", device->id);
+ pa_strbuf_printf(buf, " ID : %u\n", device->id);
+ pa_strbuf_printf(buf, " Type : %s\n", device->type);
+ pa_strbuf_printf(buf, " Name : %s\n", device->name);
+ pa_strbuf_printf(buf, " System ID : %s\n", device->system_id);
+ pa_strbuf_printf(buf, " Direction : %s\n", device_direction_to_string(device->direction));
+ pa_strbuf_printf(buf, " Is activated : %s\n", pa_yes_no(COMPOUND_STATE(device) == DM_DEVICE_STATE_ACTIVATED));
+ pa_strbuf_printf(buf, " Internal : %s\n", pa_yes_no(device->use_internal_codec));
+ if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO))
+ pa_strbuf_printf(buf, " SCO opened : %s\n", pa_yes_no(device->sco_opened));
+ playback_str = get_playback_list_str(device->playback_devices);
+ capture_str = get_capture_list_str(device->capture_devices);
if (playback_str)
pa_strbuf_puts(buf, playback_str);
return pa_strbuf_tostring_free(buf);
}
-static char* _device_get_info_str(pa_tz_device *device) {
- pa_strbuf *buf;
- char *profile_info;
- pa_tz_profile *profile;
- uint32_t profile_idx;
-
- if (!device)
- return NULL;
-
- buf = pa_strbuf_new();
- pa_strbuf_printf(buf, "[Device #%u]\n", device->id);
- pa_strbuf_printf(buf, " ID : %u\n", device->id);
- pa_strbuf_printf(buf, " Type : %s\n", device->type);
- pa_strbuf_printf(buf, " Name : %s\n", device->name);
- if (device_type_is_multi_profile(device->type))
- pa_strbuf_printf(buf, " System ID : %s\n", device->system_id);
- pa_strbuf_printf(buf, " Active Profile : %u\n", device->active_profile);
-
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
- pa_strbuf_printf(buf, " (Profile #%d)\n", profile_idx);
- profile_info = get_device_profile_info_str(profile);
- if (profile_info)
- pa_strbuf_puts(buf, profile_info);
- pa_xfree(profile_info);
- }
-
- return pa_strbuf_tostring_free(buf);
-}
-
void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level) {
char *info;
pa_hook_fire(pa_communicator_hook(device->comm, PA_COMMUNICATOR_HOOK_DEVICE_CONNECTION_CHANGED), &hook_data);
}
-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);
-}
-
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;
data->playback_pcms= pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
data->capture_pcms = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-
- data->n_profile = 0;
}
void pa_tz_device_new_data_set_type(pa_tz_device_new_data *data, const char *type) {
pa_hashmap_put(data->capture_pcms, (void*)role, source);
}
-/* after set_type, only for multi profile type, and check direction, profile */
-void pa_tz_device_new_data_add_profile(pa_tz_device_new_data *data, pa_tz_profile_new_data *profile_data, bool as_active) {
- uint32_t profile_idx;
- pa_assert(data);
-
- profile_idx = data->n_profile;
- data->profile_data[profile_idx] = profile_data;
- if (as_active)
- data->active_profile = profile_idx;
-
- data->n_profile++;
-}
void pa_tz_device_new_data_done(pa_tz_device_new_data *data) {
pa_assert(data);
}
static int _check_valid_device_new_data(pa_tz_device_new_data *data) {
- bool is_multi_profile;
pa_assert(data);
if (data->type == NULL) {
return -1;
}
- is_multi_profile = device_type_is_multi_profile(data->type);
-
- if (is_multi_profile == false && data->direction == DM_DEVICE_DIRECTION_NONE) {
+ if (data->direction == DM_DEVICE_DIRECTION_NONE) {
pa_log_error("new data direction is none");
return -1;
}
- if (is_multi_profile == true && data->n_profile == 0) {
- pa_log_error("multi profile type, but there is no profile");
- return -1;
- }
- if (is_multi_profile == false && data->n_profile > 0) {
- pa_log_error("not multi profile type, but there are profile");
- return -1;
- }
-
return 0;
}
-static pa_tz_profile* profile_new(char *profile_str, dm_device_direction_t direction,
- pa_hashmap *playbacks, pa_hashmap *captures, bool use_internal_codec, pa_tz_device *device) {
- pa_tz_profile *profile;
-
- pa_log_info("New profile(%s) direction(%s), for device(%u)",
- pa_strempty(profile_str), device_direction_to_string(direction), device->id);
-
- profile = pa_xmalloc(sizeof(pa_tz_profile));
-
- profile->profile = pa_xstrdup(profile_str);
- profile->playback_devices = playbacks;
- profile->capture_devices = captures;
- profile->direction = direction;
- profile->playback_state = DM_DEVICE_STATE_DEACTIVATED;
- profile->capture_state = DM_DEVICE_STATE_DEACTIVATED;
- profile->device = device;
- profile->creation_time = pa_rtclock_now();
- profile->use_internal_codec = use_internal_codec;
- profile->sco_opened = false;
-
- return profile;
-}
-
-static void profile_free(pa_tz_profile *profile) {
- if (!profile)
- return;
-
- pa_log_info("Free profile(%s) for device(%u)",
- pa_strempty(profile->profile), profile->device->id);
-
- pa_xfree(profile->profile);
-
- if (profile->playback_devices)
- pa_hashmap_free(profile->playback_devices);
- if (profile->capture_devices)
- pa_hashmap_free(profile->capture_devices);
-
- pa_xfree(profile);
-}
-
-static int profile_add_sink(pa_tz_profile *profile, const char *role, pa_sink *sink) {
- pa_assert(profile);
+static int device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink) {
+ pa_assert(device);
+ pa_assert(device->playback_devices);
- if (pa_hashmap_put(profile->playback_devices, (void*)role, sink) < 0) {
+ if (pa_hashmap_put(device->playback_devices, (void*)role, sink) < 0) {
pa_log_error("Failed to add sink : put sink failed");
return -1;
}
return 0;
}
-static int profile_add_source(pa_tz_profile *profile, const char *role, pa_source *source) {
- pa_assert(profile);
+static int device_add_source(pa_tz_device *device, const char *role, pa_source *source) {
+ pa_assert(device);
+ pa_assert(device->capture_devices);
- if (pa_hashmap_put(profile->capture_devices, (void*)role, source) < 0) {
+ if (pa_hashmap_put(device->capture_devices, (void*)role, source) < 0) {
pa_log_error("Failed to add source : put source failed");
return -1;
}
return 0;
}
-static pa_sink* profile_get_sink(pa_tz_profile *profile, const char *role) {
+static pa_sink* device_get_sink(pa_tz_device *device, const char *role) {
pa_sink *sink;
- pa_assert(profile);
+ pa_assert(device);
+ pa_assert(device->playback_devices);
- if ((sink = pa_hashmap_get(profile->playback_devices, role)) == NULL) {
+ if ((sink = pa_hashmap_get(device->playback_devices, role)) == NULL) {
pa_log_warn("Failed to get sink for %s", role);
return NULL;
}
return sink;
}
-static pa_source* profile_get_source(pa_tz_profile *profile, const char *role) {
+static pa_source* device_get_source(pa_tz_device *device, const char *role) {
pa_source *source;
- pa_assert(profile);
+ pa_assert(device);
+ pa_assert(device->capture_devices);
- if ((source = pa_hashmap_get(profile->capture_devices, role)) == NULL) {
+ if ((source = pa_hashmap_get(device->capture_devices, role)) == NULL) {
pa_log_warn("Failed to get source for %s", role);
return NULL;
}
return source;
}
-static void profile_set_state(pa_tz_profile *profile, dm_device_direction_t direction, dm_device_state_t state) {
+static void device_set_state(pa_tz_device *device, dm_device_direction_t direction, dm_device_state_t state) {
dm_device_state_t prev_state, new_state;
- pa_assert(profile);
+ pa_assert(device);
- prev_state = COMPOUND_STATE(profile);
- pa_log_debug("previous playback_state : %d, capture_state : %d => state %d", profile->playback_state, profile->capture_state, prev_state);
+ prev_state = COMPOUND_STATE(device);
+ pa_log_debug("previous playback_state : %d, capture_state : %d => state %d", device->playback_state, device->capture_state, prev_state);
if (direction & DM_DEVICE_DIRECTION_IN)
- profile->capture_state = state;
+ device->capture_state = state;
if (direction & DM_DEVICE_DIRECTION_OUT)
- profile->playback_state = state;
- new_state = COMPOUND_STATE(profile);
- pa_log_debug("new playback_state : %d, capture_state : %d => state %d", profile->playback_state, profile->capture_state, new_state);
+ device->playback_state = state;
+ new_state = COMPOUND_STATE(device);
+ pa_log_debug("new playback_state : %d, capture_state : %d => state %d", device->playback_state, device->capture_state, new_state);
if (prev_state != new_state) {
- notify_device_state_changed(profile->device, new_state);
- pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+ notify_device_state_changed(device, new_state);
+ pa_tz_device_dump_info(device, PA_LOG_DEBUG);
}
}
-static dm_device_state_t profile_get_state(pa_tz_profile *profile, dm_device_direction_t direction) {
- pa_assert(profile);
+static dm_device_state_t device_get_state(pa_tz_device *device, dm_device_direction_t direction) {
+ pa_assert(device);
if (direction == DM_DEVICE_DIRECTION_BOTH)
- return COMPOUND_STATE(profile);
+ return COMPOUND_STATE(device);
else if (direction == DM_DEVICE_DIRECTION_OUT)
- return profile->playback_state;
+ return device->playback_state;
else if (direction == DM_DEVICE_DIRECTION_IN)
- return profile->capture_state;
+ return device->capture_state;
else
return DM_DEVICE_STATE_DEACTIVATED;
}
-static int profile_remove_sink_with_role(pa_tz_profile *profile, const char *role) {
+static int device_remove_sink_with_role(pa_tz_device *device, const char *role) {
pa_sink *sink;
- pa_assert(profile);
+ pa_assert(device);
- sink = pa_hashmap_remove(profile->playback_devices, role);
+ sink = pa_hashmap_remove(device->playback_devices, role);
return sink ? 0 : -1;
}
-static int profile_remove_source_with_role(pa_tz_profile *profile, const char *role) {
+static int device_remove_source_with_role(pa_tz_device *device, const char *role) {
pa_source *source;
- pa_assert(profile);
+ pa_assert(device);
- source = pa_hashmap_remove(profile->capture_devices, role);
+ source = pa_hashmap_remove(device->capture_devices, role);
return source ? 0 : -1;
}
-static int profile_remove_sink(pa_tz_profile *profile, pa_sink *sink) {
+static int device_remove_sink(pa_tz_device *device, pa_sink *sink) {
pa_sink *_sink;
void *state;
char *role;
- pa_assert(profile);
+ pa_assert(device);
- PA_HASHMAP_FOREACH_KEY(_sink, profile->playback_devices, state, role) {
+ PA_HASHMAP_FOREACH_KEY(_sink, device->playback_devices, state, role) {
if (sink == _sink)
- return profile_remove_sink_with_role(profile, role);
+ return device_remove_sink_with_role(device, role);
}
return -1;
}
-static int profile_remove_source(pa_tz_profile *profile, pa_source *source) {
+static int device_remove_source(pa_tz_device *device, pa_source *source) {
pa_source *_source;
void *state;
char *role;
- pa_assert(profile);
+ pa_assert(device);
- PA_HASHMAP_FOREACH_KEY(_source, profile->capture_devices, state, role) {
+ PA_HASHMAP_FOREACH_KEY(_source, device->capture_devices, state, role) {
if (source == _source)
- return profile_remove_source_with_role(profile, role);
+ return device_remove_source_with_role(device, role);
}
return -1;
pa_tz_device *device;
pa_sink *sink;
pa_source *source;
- pa_tz_profile *profile;
- uint32_t profile_idx;
pa_assert(data);
else
device->name = pa_xstrdup(data->type);
device->system_id = pa_xstrdup(data->system_id);
- device->active_profile = 0;
pa_log_info("New device type(%s) id(%u) name(%s) system_id(%s)",
device->type, device->id, device->name, pa_strempty(device->system_id));
- device->profiles = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+ device->playback_devices = data->playback_pcms;
+ device->capture_devices = data->capture_pcms;
+ device->direction = data->direction;
+ device->playback_state = DM_DEVICE_STATE_DEACTIVATED;
+ device->capture_state = DM_DEVICE_STATE_DEACTIVATED;
+ device->creation_time = pa_rtclock_now();
+ device->use_internal_codec = data->use_internal_codec;
+ device->sco_opened = false;
- /* If multi profile type, get from data->profile_data */
- if (device_type_is_multi_profile(data->type)) {
- pa_tz_profile_new_data *pdata;
- for (int i = 0; i < data->n_profile; i++) {
- pdata = data->profile_data[i];
- profile = profile_new(pdata->profile, pdata->direction,
- pdata->playback_pcms, pdata->capture_pcms, pdata->use_internal_codec, device);
- pa_idxset_put(device->profiles, profile, NULL);
- }
- device->active_profile = data->active_profile;
- } else {
- profile = profile_new(NULL, data->direction,
- data->playback_pcms, data->capture_pcms, data->use_internal_codec, device);
- pa_idxset_put(device->profiles, profile, NULL);
- }
-
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
- if (device_type_is_use_external_card(device->type, profile->profile)) {
- if ((sink = profile_get_sink(profile, DEVICE_ROLE_NORMAL)))
- sink->device_item = device;
- if ((source = profile_get_source(profile, DEVICE_ROLE_NORMAL)))
- source->device_item = device;
- }
+ if (device_type_is_use_external_card(device->type)) {
+ if ((sink = device_get_sink(device, DEVICE_ROLE_NORMAL)))
+ sink->device_item = device;
+ if ((source = device_get_source(device, DEVICE_ROLE_NORMAL)))
+ source->device_item = device;
}
pa_idxset_put(device->list, device, NULL);
return device;
}
-static uint32_t _get_profile_idx(pa_tz_device *device, const char *profile_str) {
- pa_tz_profile *profile;
- uint32_t profile_idx;
-
- pa_assert(device);
- pa_assert(device->profiles);
-
- if (profile_str == NULL || pa_streq(profile_str, "")) {
- pa_idxset_first(device->profiles, &profile_idx);
- return profile_idx;
- }
-
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
- if (device_profile_is_equal(profile->profile, profile_str))
- return profile_idx;
- }
-
- return PA_INVALID_INDEX;
-}
-
-static pa_tz_profile* _get_profile(pa_tz_device *device, const char *profile_str) {
- pa_tz_profile *profile;
- uint32_t profile_idx;
-
- pa_assert(device);
- pa_assert(device->profiles);
-
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
- if (device_profile_is_equal(profile->profile, profile_str))
- return profile;
- }
-
- return NULL;
-}
-
-static pa_tz_profile* _get_profile_by_idx(pa_tz_device *device, uint32_t profile_idx) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- profile = pa_idxset_get_by_index(device->profiles, profile_idx);
- if (profile == NULL)
- pa_log_error("No profile(%u) in device(%u)", profile_idx, device->id);
-
- return profile;
-}
-
-
-static pa_tz_profile* _get_active_profile(pa_tz_device *device) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- profile = _get_profile_by_idx(device, device->active_profile);
- if (profile == NULL)
- pa_log_error("Failed to find active profile(%u)", device->active_profile);
-
- return profile;
-}
-
-/* if profile is null, set first profile as active */
-int _set_active_profile(pa_tz_device *device, const char *profile, bool noti) {
- uint32_t profile_idx, prev_active_idx;
-
- pa_assert(device);
-
- pa_log_info("Set active profile, device(%u) profile(%s)",
- device->id, pa_strempty(profile));
-
- prev_active_idx = device->active_profile;
- profile_idx = _get_profile_idx(device, profile);
- if (profile_idx == PA_INVALID_INDEX) {
- pa_log_error("index for profile(%s) is invalid", pa_strempty(profile));
- return -1;
- }
- device->active_profile = profile_idx;
- pa_log_info("active profile index: prev(%u) -> new(%u)", prev_active_idx, profile_idx);
-
- if (noti)
- notify_device_profile_changed(device, PA_TZ_DEVICE_ACTIVE_PROFILE_CHANGED);
-
- return 0;
-}
-
-/* only for multi profile type */
-int pa_tz_device_add_profile(pa_tz_device *device, pa_tz_profile_new_data *pdata, bool as_active) {
- pa_tz_profile *profile;
-
- pa_assert(device);
- pa_assert(device->profiles);
-
- pa_log_info("device add profile, device(%u) profile(%s) as_active(%s)",
- device->id, pa_strempty(pdata->profile), pa_yes_no(as_active));
-
- if (device_type_is_multi_profile(device->type) == false) {
- pa_log_error("Failed to add profile : not multi profile type");
- return -1;
- }
- if (pa_idxset_size(device->profiles) >= PROFILE_NUM_MAX) {
- pa_log_error("Failed to add profile : Too many profiles");
- return -1;
- }
-
- profile = profile_new(pdata->profile, pdata->direction,
- pdata->playback_pcms, pdata->capture_pcms, pdata->use_internal_codec, device);
- pa_idxset_put(device->profiles, profile, NULL);
-
- 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;
-}
-
-int pa_tz_device_remove_profile(pa_tz_device *device, const char *profile_str) {
- pa_tz_profile *profile;
- uint32_t profile_idx, remove_idx;
- bool found = false;
- unsigned profile_num;
-
- pa_assert(device);
- pa_assert(device->profiles);
-
- pa_log_info("device remove profile, device(%u) profile(%s)",
- device->id, pa_strempty(profile_str));
-
- if (device_type_is_multi_profile(device->type) == false) {
- pa_log_error("Failed to add profile : not multi profile type");
- return -1;
- }
-
- if ((profile_num = pa_tz_device_get_profile_num(device)) <= 1) {
- pa_log_error("This device have too small profiles %u, Should be freed", profile_num);
- return -1;
- }
-
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx) {
- if (pa_safe_streq(profile->profile, profile_str)) {
- pa_log_info("found matching profile to remove");
- found = true;
- remove_idx = profile_idx;
- }
- }
-
- if (found) {
- pa_idxset_remove_by_index(device->profiles, remove_idx);
- /* 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 {
- pa_log_warn("no matching profile to remove");
- return -1;
- }
-}
-
-/* only for single profile type */
int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink) {
- pa_tz_profile *profile;
-
pa_assert(device);
pa_assert(device_role_is_valid(role));
pa_assert(sink);
pa_log_info("device add sink, device(%u) role(%s) sink(%s)",
device->id, role, sink->name);
- if (pa_tz_device_get_profile_num(device) > 1) {
- pa_log_error("Failed to add sink : Too many profiles");
- return -1;
- }
-
- profile = pa_idxset_first(device->profiles, NULL);
-
- if (profile_add_sink(profile, role, sink) < 0) {
- pa_log_error("Failed to add sink : Can't add to profile");
+ if (device_add_sink(device, role, sink) < 0) {
+ pa_log_error("Failed to add sink : Can't add to device");
return -1;
}
}
int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *source) {
- pa_tz_profile *profile;
-
pa_assert(device);
pa_assert(device_role_is_valid(role));
pa_assert(source);
pa_log_info("device add source, device(%u) role(%s) source(%s)",
device->id, role, source->name);
- if (pa_tz_device_get_profile_num(device) > 1) {
- pa_log_warn("Failed to add source : Too many profiles");
- return -1;
- }
-
- profile = pa_idxset_first(device->profiles, NULL);
-
- if (profile_add_source(profile, role, source) < 0) {
- pa_log_error("Failed to add source : Can't add to profile");
+ if (device_add_source(device, role, source) < 0) {
+ pa_log_error("Failed to add source : Can't add to device");
return -1;
}
}
int pa_tz_device_remove_sink(pa_tz_device *device, pa_sink *sink) {
- pa_tz_profile *profile;
- int removed = 0;
- uint32_t profile_idx;
-
pa_assert(device);
pa_assert(sink);
pa_log_info("device remove sink, device(%u) sink(%s)",
device->id, sink->name);
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
- removed &= profile_remove_sink(profile, sink);
-
- return removed;
+ return device_remove_sink(device, sink);
}
int pa_tz_device_remove_source(pa_tz_device *device, pa_source *source) {
- pa_tz_profile *profile;
- uint32_t profile_idx;
- int removed = 0;
-
pa_assert(device);
pa_assert(source);
pa_log_info("device remove source, device(%u) source(%s)",
device->id, source->name);
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
- removed &= profile_remove_source(profile, source);
-
- return removed;
+ return device_remove_source(device, source);
}
int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role) {
- pa_tz_profile *profile;
- uint32_t profile_idx;
- int removed = 0;
-
pa_assert(device);
pa_assert(device_role_is_valid(role));
pa_log_info("device remove sink with role, device(%u) role(%s)",
device->id, role);
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
- removed &= profile_remove_sink_with_role(profile, role);
-
- return removed;
+ return device_remove_sink_with_role(device, role);
}
int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role) {
- pa_tz_profile *profile;
- uint32_t profile_idx;
- int removed = 0;
-
pa_assert(device);
pa_assert(device_role_is_valid(role));
pa_log_info("device remove source with role, device(%u) role(%s)",
device->id, role);
- PA_IDXSET_FOREACH(profile, device->profiles, profile_idx)
- removed &= profile_remove_source_with_role(profile, role);
-
- return removed;
-}
-
-/* only for multi profile */
-int pa_tz_device_profile_add_sink(pa_tz_device *device, const char *profile_str, const char *role, pa_sink *sink) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile add sink, device(%u) profile(%s) role(%s) sink(%s)",
- device->id, pa_strempty(profile_str), role, sink->name);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_add_sink(profile, role, sink) < 0) {
- pa_log_error("Can't add to profile");
- return -1;
- }
-
- return 0;
-}
-
-int pa_tz_device_profile_add_source(pa_tz_device *device, const char *profile_str, const char *role, pa_source *source) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile add source, device(%u) profile(%s) role(%s) source(%s)",
- device->id, pa_strempty(profile_str), role, source->name);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_add_source(profile, role, source) < 0) {
- pa_log_error("Can't add to profile");
- return -1;
- }
-
- return 0;
-}
-
-int pa_tz_device_profile_remove_sink(pa_tz_device *device, const char *profile_str, pa_sink *sink) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile remove sink, device(%u) profile(%s) sink(%s)",
- device->id, pa_strempty(profile_str), sink->name);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_remove_sink(profile, sink) < 0) {
- pa_log_error("Can't remove from profile");
- return -1;
- }
-
- return 0;
-}
-
-int pa_tz_device_profile_remove_source(pa_tz_device *device, const char *profile_str, pa_source *source) {
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile remove source, device(%u) profile(%s) source(%s)",
- device->id, pa_strempty(profile_str), source->name);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_remove_source(profile, source) < 0) {
- pa_log_error("Can't remove from profile");
- return -1;
- }
-
- return 0;
-}
-
-int pa_tz_device_profile_remove_sink_with_role(pa_tz_device *device, const char *profile_str, const char *role) {
- pa_tz_profile *profile;
-
- pa_assert(device);
- pa_assert(device_role_is_valid(role));
-
- pa_log_info("device profile remove sink with role, device(%u) profile(%s) role(%s)",
- device->id, pa_strempty(profile_str), role);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_remove_sink_with_role(profile, role) < 0) {
- pa_log_error("Can't remove from profile");
- return -1;
- }
-
- return 0;
-}
-
-int pa_tz_device_profile_remove_source_with_role(pa_tz_device *device, const char *profile_str, const char *role) {
- pa_tz_profile *profile;
-
- pa_assert(device);
- pa_assert(device_role_is_valid(role));
-
- pa_log_info("device profile remove source with role, device(%u) profile(%s) role(%s)",
- device->id, pa_strempty(profile_str), role);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return -1;
- }
-
- if (profile_remove_source_with_role(profile, role) < 0) {
- pa_log_error("Can't remove from profile");
- return -1;
- }
-
- return 0;
-}
-
-pa_sink* pa_tz_device_profile_get_sink(pa_tz_device *device, const char *profile_str, const char *role) {
- pa_sink *sink;
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile get sink, device(%u) profile(%s) role(%s)",
- device->id, pa_strempty(profile_str), role);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return NULL;
- }
-
- if ((sink = profile_get_sink(profile, role)) == NULL) {
- pa_log_error("Can't get sink from profile");
- return NULL;
- }
-
- return sink;
-}
-
-pa_source* pa_tz_device_profile_get_source(pa_tz_device *device, const char *profile_str, const char *role) {
- pa_source *source;
- pa_tz_profile *profile;
-
- pa_assert(device);
-
- pa_log_info("device profile get source, device(%u) profile(%s) role(%s)",
- device->id, pa_strempty(profile_str), role);
-
- if ((profile = _get_profile(device, profile_str)) == NULL) {
- pa_log_error("Can't get profile %s", profile_str);
- return NULL;
- }
-
- if ((source = profile_get_source(profile, role)) == NULL) {
- pa_log_error("Can't get source from profile");
- return NULL;
- }
-
- return source;
+ return device_remove_source_with_role(device, role);
}
void pa_tz_device_free(pa_tz_device *device) {
pa_xfree(device->name);
pa_xfree(device->system_id);
- pa_idxset_free(device->profiles, (pa_free_cb_t)profile_free);
-
pa_xfree(device);
}
-/* pa_tz_profile_new_data */
-void pa_tz_profile_new_data_init(pa_tz_profile_new_data *profile_data) {
- pa_assert(profile_data);
-
- profile_data->profile = NULL;
- profile_data->direction = DM_DEVICE_DIRECTION_NONE;
-
- profile_data->playback_pcms= pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- profile_data->capture_pcms = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-}
-
-void pa_tz_profile_new_data_set_direction(pa_tz_profile_new_data *profile_data, dm_device_direction_t direction) {
- pa_assert(profile_data);
-
- profile_data->direction = direction;
-}
-
-void pa_tz_profile_new_data_set_profile(pa_tz_profile_new_data *profile_data, const char *profile) {
- pa_assert(profile_data);
-
- profile_data->profile = pa_xstrdup(profile);
-}
-
-void pa_tz_profile_new_data_set_use_internal_codec(pa_tz_profile_new_data *profile_data, bool use_internal_codec) {
- pa_assert(profile_data);
- profile_data->use_internal_codec = use_internal_codec;
-}
-
-void pa_tz_profile_new_data_add_sink(pa_tz_profile_new_data *profile_data, const char *role, pa_sink *sink) {
- pa_assert(profile_data);
-
- pa_hashmap_put(profile_data->playback_pcms, (void*)role, sink);
-}
-
-void pa_tz_profile_new_data_add_source(pa_tz_profile_new_data *profile_data, const char *role, pa_source *source) {
- pa_assert(profile_data);
-
- pa_hashmap_put(profile_data->capture_pcms, (void*)role, source);
-}
-
-void pa_tz_profile_new_data_done(pa_tz_profile_new_data *profile_data) {
- pa_assert(profile_data);
-
- pa_xfree(profile_data->profile);
-}
-
/* exported api */
pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role) {
- pa_tz_profile *profile;
pa_sink *sink;
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- pa_log_info("device get sink, device(%u) role(%s), active-profile(%s)",
- device->id, role, pa_strempty(profile->profile));
+ pa_log_info("device get sink, device(%u) role(%s)", device->id, role);
- if ((sink = profile_get_sink(profile, role)) == NULL) {
- pa_log_error("Failed to get sink from profile");
+ if ((sink = device_get_sink(device, role)) == NULL) {
+ pa_log_error("Failed to get sink from device");
return NULL;
}
}
pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role) {
- pa_tz_profile *profile;
pa_source *source;
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- pa_log_info("device get source, device(%u) role(%s), active-profile(%s)",
- device->id, role, pa_strempty(profile->profile));
+ pa_log_info("device get source, device(%u) role(%s)",
+ device->id, role);
- if ((source = profile_get_source(profile, role)) == NULL) {
- pa_log_error("Failed to get source from profile");
+ if ((source = device_get_source(device, role)) == NULL) {
+ pa_log_error("Failed to get source from device");
return NULL;
}
/* 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;
-
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- pa_log_info("device set state, device(%u) type(%s) active-profile(%s) direction(%s) -> %d",
- device->id, device->type, pa_strempty(profile->profile), device_direction_to_string(direction), state);
- profile_set_state(profile, direction, state);
+ pa_log_info("device set state, device(%u) type(%s) direction(%s) -> %d",
+ device->id, device->type, device_direction_to_string(direction), state);
+ device_set_state(device, direction, state);
}
dm_device_state_t pa_tz_device_get_state(pa_tz_device *device, dm_device_direction_t direction) {
- pa_tz_profile *profile;
-
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- return profile_get_state(profile, direction);
+ return device_get_state(device, direction);
}
uint32_t pa_tz_device_get_id(pa_tz_device *device) {
return device->system_id;
}
-char* pa_tz_device_get_profile(pa_tz_device *device) {
- pa_tz_profile *profile;
-
- pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
-
- return profile->profile;
-}
-
dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device) {
- pa_tz_profile *profile;
-
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- return profile->direction;
+ return device->direction;
}
pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device) {
- pa_tz_profile *profile;
-
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- return profile->creation_time;
+ return device->creation_time;
}
bool pa_tz_device_is_use_internal_codec(pa_tz_device *device) {
- pa_tz_profile *profile;
-
pa_assert(device);
- pa_assert(profile = _get_active_profile(device));
- return profile->use_internal_codec;
-}
-
-unsigned pa_tz_device_get_profile_num(pa_tz_device *device) {
- pa_assert(device);
- pa_assert(device->profiles);
-
- return pa_idxset_size(device->profiles);
-}
-
-bool pa_tz_device_have_profile(pa_tz_device *device, const char *profile) {
- pa_assert(device);
-
- if (_get_profile(device, profile) == NULL)
- return false;
- else
- return true;
+ return device->use_internal_codec;
}
static int method_call_bt_sco(pa_dbus_connection *conn, bool onoff) {
return 0;
}
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
int pa_tz_device_sco_open(pa_tz_device *device) {
- pa_tz_profile *profile;
-
pa_assert(device);
pa_assert(device->dbus_conn);
pa_log_info("BT SCO Open for device(%u)", device->id);
- if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
- pa_log_error("Not BT device");
- return -1;
- }
- if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
- pa_log_error("No BT SCO profile");
+ if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
+ pa_log_error("Not BT SCO device");
return -1;
}
- if (profile->sco_opened) {
+ if (device->sco_opened) {
pa_log_warn("SCO already opened");
return -1;
}
return -1;
}
- profile->sco_opened = true;
- _set_active_profile(device, DEVICE_PROFILE_BT_SCO, false);
- pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+ device->sco_opened = true;
+ pa_tz_device_dump_info(device, PA_LOG_DEBUG);
pa_log_info("BT SCO Open - SUCCESS");
return 0;
}
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
int pa_tz_device_sco_close(pa_tz_device *device) {
- pa_tz_profile *profile;
pa_assert(device);
pa_log_info("BT SCO Close for device(%u)", device->id);
- if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
- pa_log_error("Not BT device");
- return -1;
- }
- if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
- pa_log_error("No BT SCO profile");
+ if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
+ pa_log_error("Not BT SCO device");
return -1;
}
- if (profile->sco_opened == false) {
+ if (device->sco_opened == false) {
pa_log_warn("SCO not opened");
return -1;
}
return -1;
}
- profile->sco_opened = false;
- if (pa_tz_device_have_profile(device, DEVICE_PROFILE_BT_A2DP))
- _set_active_profile(device, DEVICE_PROFILE_BT_A2DP, false);
- pa_tz_device_dump_info(profile->device, PA_LOG_DEBUG);
+ device->sco_opened = false;
+ pa_tz_device_dump_info(device, PA_LOG_DEBUG);
pa_log_info("BT SCO Close - Success");
return 0;
}
-/* only for bt device, which have sco profile */
+/* only for bt sco device */
int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec) {
pa_assert(device);
pa_log_info("BT SCO get property for device(%u)", device->id);
- if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
+ if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
pa_log_error("Not BT device");
return -1;
}
- if ((_get_profile(device, DEVICE_PROFILE_BT_SCO)) == NULL) {
- pa_log_error("No BT SCO profile");
- return -1;
- }
if (method_call_bt_sco_get_property(device->dbus_conn, is_wide_band, nrec) < 0) {
pa_log_error("Failed to get BT SCO Property");
return 0;
}
-/* only for bt device */
+/* only for bt sco device */
int pa_tz_device_sco_get_status(pa_tz_device *device, dm_device_bt_sco_status_t *status) {
- pa_tz_profile *profile;
pa_assert(device);
pa_log_info("BT SCO get status for device(%u)", device->id);
- if (pa_streq(device->type, DEVICE_TYPE_BT) == false) {
+ if (device_type_is_equal(device->type, DEVICE_TYPE_BT_SCO) == false) {
pa_log_error("Not BT device");
return -1;
}
return -1;
}
- if ((profile = _get_profile(device, DEVICE_PROFILE_BT_SCO))) {
- if (profile->sco_opened == false)
- *status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
- else
- *status = DM_DEVICE_BT_SCO_STATUS_OPENED;
- } else {
- *status = DM_DEVICE_BT_SCO_STATUS_DISCONNECTED;
- }
+ if (device->sco_opened == false)
+ *status = DM_DEVICE_BT_SCO_STATUS_CONNECTED;
+ else
+ *status = DM_DEVICE_BT_SCO_STATUS_OPENED;
pa_log_debug("BT SCO Get Status, %d", *status);
return 0;
#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;
-typedef struct pa_tz_profile_new_data pa_tz_profile_new_data;
/* structures for represent device items which can be connected/disconnected */
-/*
- Before beginning, There are two structure(pa_tz_device, pa_tz_profile)
- for represent device by following reasons.
- When bt-a2dp and bt-sco are on physically same device ,it is of course same device.
- So those physically same device item are represended by pa_tz_device,
- and each profile is represented by pa_tz_profile.
-*/
/*
- Structure to represent physicall device,
- which can have multiple profiles (ex. bt-a2dp and sco).
If this is created or freed, device connected/disconnected
hook(for internal)/callback(for apps) will be called.
*/
* each physicall device */
char *system_id;
- /* Even though there are several profiles in device,
- * only one profile can be activated.
- * This indicate current activat profile */
- uint32_t active_profile;
- /* Have only one item except bt device */
- /* pa_tz_profile* profiles[PROFILE_NUM_MAX]; */
- pa_idxset *profiles;
+ dm_device_direction_t direction;
+
+ /* Set by stream-manager
+ * If this is changed, will be notifacted */
+ dm_device_state_t playback_state;
+ dm_device_state_t capture_state;
+
+ /* Can get proper sink/source in hashmaps with key(=device_role) */
+ pa_hashmap *playback_devices;
+ pa_hashmap *capture_devices;
+
+ /* creation time */
+ pa_usec_t creation_time;
+
+ /* Will be true, if this device uses internal codec(card),
+ * false, if this device uses external card(bt-a2dp, usb */
+ bool use_internal_codec;
+ /* If this is sco device, this can be used to */
+ bool sco_opened;
/* Devices are contained in this list */
pa_idxset *list;
/* for multi-device type(bt, usb) */
char *system_id;
- /* for solo profile type */
dm_device_direction_t direction;
bool use_internal_codec;
pa_hashmap *playback_pcms;
pa_hashmap *capture_pcms;
- /* for multi profile type */
- pa_tz_profile_new_data* profile_data[PROFILE_NUM_MAX];
- uint32_t n_profile;
- uint32_t active_profile;
-
pa_idxset *list;
pa_communicator *comm;
pa_dbus_connection *dbus_conn;
};
-struct pa_tz_profile_new_data {
- char *profile;
- dm_device_direction_t direction;
-
- pa_hashmap *playback_pcms;
- pa_hashmap *capture_pcms;
-
- bool use_internal_codec;
-};
-
-/*
- Structure to represent each device profile (subtype).
- Even if both-way device(earjack, sco..) ,one device_profile.
-*/
-struct pa_tz_profile {
- /* This can be null except bt device */
- char *profile;
- dm_device_direction_t direction;
-
- /* Set by stream-manager
- * If this is changed, will be notifacted */
- dm_device_state_t playback_state;
- dm_device_state_t capture_state;
-
- /* Can get proper sink/source in hashmaps with key(=device_role) */
- pa_hashmap *playback_devices;
- pa_hashmap *capture_devices;
-
- /* device belongs to */
- pa_tz_device *device;
-
- /* creation time */
- pa_usec_t creation_time;
-
- /* Will be true, if this profile uses internal codec(card),
- * false, if this profile uses external card(bt-a2dp, usb */
- bool use_internal_codec;
- /* If this is sco profile, this can be used to */
- bool sco_opened;
-};
-
typedef struct _hook_call_data_for_conn_changed {
uint32_t event_id;
bool is_connected;
pa_tz_device *device;
} 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_state_changed {
uint32_t event_id;
bool activated;
void pa_tz_device_new_data_add_sink(pa_tz_device_new_data *data, const char *role, pa_sink *sink);
void pa_tz_device_new_data_add_source(pa_tz_device_new_data *data, const char *role, pa_source *source);
void pa_tz_device_new_data_done(pa_tz_device_new_data *data);
-/* For multi profile device */
-void pa_tz_device_new_data_add_profile(pa_tz_device_new_data *data, pa_tz_profile_new_data *profile_data, bool as_active);
/* Create tizen device instance,
* device connected hook will be fired */
int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role);
int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role);
-/* For multi profile device */
-int pa_tz_device_add_profile(pa_tz_device *device, pa_tz_profile_new_data *pdata, bool as_active);
-int pa_tz_device_remove_profile(pa_tz_device *device, const char *profile);
-int pa_tz_device_profile_add_sink(pa_tz_device *device, const char *profile, const char *role, pa_sink *sink);
-int pa_tz_device_profile_add_source(pa_tz_device *device, const char *profile, const char *role, pa_source *source);
-int pa_tz_device_profile_remove_sink(pa_tz_device *device, const char *profile, pa_sink *sink);
-int pa_tz_device_profile_remove_source(pa_tz_device *device, const char *profile, pa_source *source);
-int pa_tz_device_profile_remove_sink_with_role(pa_tz_device *device, const char *profile, const char *role);
-int pa_tz_device_profile_remove_source_with_role(pa_tz_device *device, const char *profile, const char *role);
-pa_sink* pa_tz_device_profile_get_sink(pa_tz_device *device, const char *profile, const char *role);
-pa_source* pa_tz_device_profile_get_source(pa_tz_device *device, const char *profile, const char *role);
-
-/* This APIs can be used with pa_tz_device_new_data_add_profile or
- * pa_tz_device_add_profile */
-void pa_tz_profile_new_data_init(pa_tz_profile_new_data *profile_data);
-void pa_tz_profile_new_data_set_direction(pa_tz_profile_new_data *profile_data, dm_device_direction_t direction);
-void pa_tz_profile_new_data_set_profile(pa_tz_profile_new_data *profile_data, const char *profile);
-void pa_tz_profile_new_data_set_use_internal_codec(pa_tz_profile_new_data *profile_data, bool use_internal_codec);
-void pa_tz_profile_new_data_add_sink(pa_tz_profile_new_data *profile_data, const char *role, pa_sink *sink);
-void pa_tz_profile_new_data_add_source(pa_tz_profile_new_data *profile_data, const char *role, pa_source *source);
-void pa_tz_profile_new_data_done(pa_tz_profile_new_data *profile_data);
-
/* Exported API for other modules */
pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role);
pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role);
char* pa_tz_device_get_type(pa_tz_device *device);
char* pa_tz_device_get_name(pa_tz_device *device);
char* pa_tz_device_get_system_id(pa_tz_device *device);
-char* pa_tz_device_get_profile(pa_tz_device *device);
dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device);
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
- * with pa_tz_device_have_profile */
+/* Only for BT SCO device */
int pa_tz_device_sco_open(pa_tz_device *device);
int pa_tz_device_sco_close(pa_tz_device *device);
int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec);