Lines Matching defs:device

208     t->device = d;
257 bool pa_bluetooth_device_supports_profile(const pa_bluetooth_device *device, pa_bluetooth_profile_t profile) {
260 pa_assert(device);
265 if (!device->adapter) {
267 device->alias, device->address, pa_bluetooth_profile_to_string(profile));
271 if (device->enable_hfp_hf) {
272 show_hfp = pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HFP_HF);
281 r = !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_A2DP_SINK) &&
282 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_A2DP_SOURCE));
285 r = !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_A2DP_SOURCE) &&
286 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_A2DP_SINK));
290 && ( !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HSP_HS) &&
291 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HSP_AG)) ||
292 !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HSP_HS_ALT) &&
293 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HSP_AG)) );
296 r = !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HSP_AG) &&
297 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HSP_HS)) ||
298 !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HSP_AG) &&
299 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HSP_HS_ALT));
303 && !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HFP_HF) &&
304 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HFP_AG));
307 r = !!(pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HFP_AG) &&
308 pa_hashmap_get(device->adapter->uuids, PA_BLUETOOTH_UUID_HFP_HF));
316 pa_log_debug("Checking if device %s (%s) supports profile %s: %s",
317 device->alias, device->address, pa_bluetooth_profile_to_string(profile), r ? "true" : "false");
322 static bool device_is_profile_connected(pa_bluetooth_device *device, pa_bluetooth_profile_t profile) {
323 if (device->transports[profile] && device->transports[profile]->state != PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
329 static unsigned device_count_disconnected_profiles(pa_bluetooth_device *device) {
334 if (!pa_bluetooth_device_supports_profile(device, profile))
337 if (!device_is_profile_connected(device, profile))
344 static void device_stop_waiting_for_profiles(pa_bluetooth_device *device) {
345 if (!device->wait_for_profiles_timer)
348 device->discovery->core->mainloop->time_free(device->wait_for_profiles_timer);
349 device->wait_for_profiles_timer = NULL;
353 pa_bluetooth_device *device = userdata;
359 device_stop_waiting_for_profiles(device);
364 if (device_is_profile_connected(device, profile))
367 if (!pa_bluetooth_device_supports_profile(device, profile))
379 pa_log_debug("Timeout expired, and device %s still has disconnected profiles: %s",
380 device->path, profiles_str);
382 pa_hook_fire(&device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], device);
385 static void device_start_waiting_for_profiles(pa_bluetooth_device *device) {
386 pa_assert(!device->wait_for_profiles_timer);
387 device->wait_for_profiles_timer = pa_core_rttime_new(device->discovery->core,
389 wait_for_profiles_cb, device);
404 pa_bluetooth_device *device;
416 device = pa_hashmap_get(y->devices, data->device_path);
417 if (!device) {
418 pa_log_error("Changing codec for device %s with profile %s failed. Device is not connected anymore",
422 pa_log_info("Changing codec for device %s with profile %s succeeded",
426 pa_log_error("Changing codec for device %s with profile %s failed. Error: %s",
437 device->codec_switching_in_progress = false;
440 bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_profile_t profile,
454 pa_assert(device);
458 if (device->codec_switching_in_progress) {
466 all_endpoints = pa_hashmap_get(is_a2dp_sink ? device->a2dp_sink_endpoints : device->a2dp_source_endpoints,
470 pa_assert_se(endpoint = endpoint_conf->choose_remote_endpoint(capabilities_hashmap, &device->discovery->core->default_sample_spec, is_a2dp_sink));
473 config_size = endpoint_conf->fill_preferred_configuration(&device->discovery->core->default_sample_spec,
495 device->codec_switching_in_progress = true;
499 data->device_path = pa_xstrdup(device->path);
504 send_and_add_to_pending(device->discovery, m, pa_bluetooth_device_switch_codec_reply, data);
520 old_any_connected = pa_bluetooth_device_any_transport_connected(t->device);
527 pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
531 * device, so that all profiles have time to get connected before the
537 n_disconnected_profiles = device_count_disconnected_profiles(t->device);
539 new_device_appeared = !old_any_connected && pa_bluetooth_device_any_transport_connected(t->device);
540 device_disconnected = old_any_connected && !pa_bluetooth_device_any_transport_connected(t->device);
544 device_start_waiting_for_profiles(t->device);
546 pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], t->device);
551 if (t->device->wait_for_profiles_timer) {
552 /* If the timer is still running when the device disconnects, we
553 * never sent the notification of the device getting connected, so
556 device_stop_waiting_for_profiles(t->device);
558 pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], t->device);
562 if (n_disconnected_profiles == 0 && t->device->wait_for_profiles_timer) {
564 * send a notification of the new device. */
565 device_stop_waiting_for_profiles(t->device);
566 pa_hook_fire(&t->device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], t->device);
578 pa_assert(t->device);
580 pa_assert(t->device->discovery);
614 pa_assert_se(dbus_connection_send(pa_dbus_connection_get(t->device->discovery->connection), m, NULL));
638 pa_assert(t->device);
640 if (!t->device->avrcp_absolute_volume)
673 pa_hook_fire(pa_bluetooth_discovery_hook(t->device->discovery, hook), t);
679 t->device->transports[t->profile] = t;
680 pa_assert_se(pa_hashmap_put(t->device->discovery->transports, t->path, t) >= 0);
688 pa_hashmap_remove(t->device->discovery->transports, t->path);
689 t->device->transports[t->profile] = NULL;
713 pa_assert(t->device);
714 pa_assert(t->device->discovery);
720 r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->device->discovery->connection), m, -1, &err);
757 pa_assert(t->device);
758 pa_assert(t->device->discovery);
768 r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->device->discovery->connection), m, -1, &err);
842 pa_assert(t->device);
843 pa_assert(t->device->discovery);
853 send_and_add_to_pending(t->device->discovery, m, get_volume_reply, t);
858 pa_assert(t->device);
860 if (!t->device->avrcp_absolute_volume)
980 /* Notify BlueZ that we're no longer providing battery info for this device */
1133 pa_bluetooth_device *device;
1138 PA_HASHMAP_FOREACH(device, y->devices, devices_state) {
1139 PA_HASHMAP_FOREACH(endpoints, device->a2dp_sink_endpoints, state)
1142 PA_HASHMAP_FOREACH(endpoints, device->a2dp_source_endpoints, state)
1257 pa_log_warn("Unknown device removed %s", path);
1264 static void device_set_valid(pa_bluetooth_device *device, bool valid) {
1267 pa_assert(device);
1269 if (valid == device->valid)
1272 old_any_connected = pa_bluetooth_device_any_transport_connected(device);
1273 device->valid = valid;
1275 if (pa_bluetooth_device_any_transport_connected(device) != old_any_connected)
1276 pa_hook_fire(&device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], device);
1301 static void device_set_adapter(pa_bluetooth_device *device, pa_bluetooth_adapter *adapter) {
1302 pa_assert(device);
1304 if (adapter == device->adapter)
1307 device->adapter = adapter;
1309 device_update_valid(device);
1539 pa_log_error("Received invalid property for device %s", d->path);
1613 /* bluetoothd never removes UUIDs from a device object so we
1657 pa_log_error("Non-optional information missing for device %s", d->path);
1880 pa_bluetooth_device *device;
1972 device = pa_hashmap_get(y->devices, device_path);
1973 if (!device) {
1979 codec_endpoints = device->a2dp_sink_endpoints;
1981 codec_endpoints = device->a2dp_source_endpoints;
2075 pa_log_error("Found duplicated D-Bus path for device %s", path);
2333 pa_log_debug("Properties changed in device %s", dbus_message_get_path(m));
2336 pa_log_warn("Properties changed in unknown device");
2536 pa_log_error("Information about device %s is invalid", dev_path);
2541 pa_log_warn("SetConfiguration() received for unknown device %s", dev_path);
2562 * the source role as it is the audio rendering device.