NULL
};
-#define BT_CVSD_CODEC_ID 1 // narrow-band
-#define BT_MSBC_CODEC_ID 2 // wide-band
-
typedef enum dm_device_class_type {
DM_DEVICE_CLASS_NONE,
DM_DEVICE_CLASS_ALSA,
PA_IDXSET_FOREACH(status_info, manager->device_status, status_idx) {
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 status_info;
- else if (status_info->system_id == NULL)
- continue;
- else if (pa_safe_streq(status_info->system_id, system_id))
+ if (system_id) {
+ if (pa_safe_streq(status_info->system_id, system_id))
return status_info;
- else
- continue;
- } else {
- return status_info;
+ continue;
}
+ return status_info;
}
}
}
}
-pa_tz_device* device_list_get_device(pa_device_manager *manager, const char *type, const char *system_id) {
+pa_tz_device* device_list_get_device(pa_device_manager *manager, const char *type, const char *role, const char *system_id) {
pa_tz_device *device;
uint32_t idx;
- char *_type, *_system_id;
pa_assert(manager);
pa_assert(manager->device_list);
pa_assert(type);
PA_IDXSET_FOREACH(device, manager->device_list, idx) {
- _type = pa_tz_device_get_type(device);
- _system_id = pa_tz_device_get_system_id(device);
- if (pa_safe_streq(_type, type)) {
- if (device_type_is_avail_multi_device(type)) {
- if (system_id == NULL)
+ if (pa_safe_streq(pa_tz_device_get_type(device), type)) {
+ /* 1. check system_id first */
+ if (system_id) {
+ if (pa_safe_streq(pa_tz_device_get_system_id(device), system_id))
return device;
- else if (_system_id == NULL)
+ else
continue;
- else if (pa_safe_streq(_system_id, system_id))
+ }
+ /* 2. check role */
+ if (role) {
+ if (pa_tz_device_get_role(device, role))
return device;
else
continue;
- } else {
- return device;
}
+ return device;
}
}
}
}
-/* Get system_id of physical device, if external device */
+/* Get system_id of physical device, it should be a unique id */
static const char* pulse_device_get_system_id(pa_object *pdevice) {
pa_proplist *prop;
return NULL;
}
- if (!(device = device_list_get_device(dm, type, NULL))) {
+ if (!(device = device_list_get_device(dm, type, NULL, NULL))) {
pa_log_warn("cannot get device item for %s", type);
return NULL;
}
return NULL;
}
- if (!(device = device_list_get_device(dm, type, NULL))) {
+ if (!(device = device_list_get_device(dm, type, NULL, NULL))) {
pa_log_warn("cannot get device item for %s", type);
return NULL;
}
pa_tz_device_new(&data);
pa_tz_device_new_data_done(&data);
} else {
- if (!(device = device_list_get_device(dm, DEVICE_TYPE_USB_AUDIO, system_id)))
+ if (!(device = device_list_get_device(dm, DEVICE_TYPE_USB_AUDIO, NULL, system_id)))
pa_log_warn("Can't get usb device for %s", system_id);
else
pa_tz_device_free(device);
pa_tz_device_new_data_done(&data);
} else {
- if (!(device = device_list_get_device(dm, DEVICE_TYPE_BT_A2DP, system_id)))
+ if (!(device = device_list_get_device(dm, DEVICE_TYPE_BT_A2DP, NULL, system_id)))
pa_log_warn("Can't get bt device for %s", system_id);
else
pa_tz_device_free(device);
pa_tz_device_new(&data);
pa_tz_device_new_data_done(&data);
} else {
- if (!(device = device_list_get_device(dm, DEVICE_TYPE_RAOP, system_id)))
+ if (!(device = device_list_get_device(dm, DEVICE_TYPE_RAOP, NULL, system_id)))
pa_log_warn("Can't get RAOP device for %s", system_id);
else
pa_tz_device_free(device);
for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
ctype = pa_dynarray_get(ctypes, i);
pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
- if ((device = device_list_get_device(dm, ctype->type, NULL))) {
+ if ((device = device_list_get_device(dm, ctype->type, NULL, 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_add_sink(device, ctype->role, PA_SINK(pdevice));
for (int i = 0; i < pa_dynarray_size(ctypes); i++) {
ctype = pa_dynarray_get(ctypes, i);
pa_log_info("Found belongs type %s %s", ctype->type, ctype->role);
- if ((device = device_list_get_device(dm, ctype->type, NULL))) {
+ if ((device = device_list_get_device(dm, ctype->type, NULL, NULL))) {
pa_log_info("Remove this pulse_device from device(%u)", pa_tz_device_get_id(device));
if (direction == DM_DEVICE_DIRECTION_OUT)
pa_tz_device_remove_sink(device, PA_SINK(pdevice));
pa_log_info("Load forwarding device");
- if ((forwarding_device = device_list_get_device(dm, DEVICE_TYPE_FORWARDING, NULL))) {
+ if ((forwarding_device = device_list_get_device(dm, DEVICE_TYPE_FORWARDING, NULL, NULL))) {
pa_log_info("Forwarding device already exists");
return forwarding_device;
}
- if ((spk_device = device_list_get_device(dm, DEVICE_TYPE_SPEAKER, NULL)) == NULL) {
+ if ((spk_device = device_list_get_device(dm, DEVICE_TYPE_SPEAKER, NULL, NULL)) == NULL) {
pa_log_error("Get speaker device failed");
return NULL;
}
PA_IDXSET_FOREACH(type_info, manager->type_infos, type_idx) {
type = type_info->type;
+
if (device_type_is_equal(type, DEVICE_TYPE_AUDIO_JACK)) {
int earjack_status = 0;
if (vconf_get_int(VCONFKEY_SYSMAN_EARJACK, &earjack_status) < 0) {
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, 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) {
}
if (miracast_wfd_status == FORWARDING_CONNECTED)
device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
+
} else {
device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED);
}
pa_tz_device* pa_device_manager_get_device(pa_device_manager *dm, const char *type) {
pa_assert(dm);
- return device_list_get_device(dm, type, NULL);
+ return device_list_get_device(dm, type, NULL, NULL);
}
pa_tz_device* pa_device_manager_get_device_by_id(pa_device_manager *dm, uint32_t id) {
void pa_device_manager_unload_forwarding(pa_device_manager *dm) {
pa_tz_device *forwarding_device;
- forwarding_device = device_list_get_device(dm, DEVICE_TYPE_FORWARDING, NULL);
+ forwarding_device = device_list_get_device(dm, DEVICE_TYPE_FORWARDING, NULL, NULL);
if (forwarding_device)
pa_tz_device_free(forwarding_device);
else