Lines Matching refs:device

116     auto device = volume_control_devices_.FindByAddress(address);  in Connect()  local
117 if (!device) { in Connect()
125 device->connecting_actively = true; in Connect()
127 if (device->IsConnected()) { in Connect()
129 device->connection_id); in Connect()
131 if (device->IsReady()) { in Connect()
133 device->address); in Connect()
135 OnGattConnected(GATT_SUCCESS, device->connection_id, gatt_if_, in Connect()
136 device->address, BT_TRANSPORT_LE, GATT_MAX_MTU_SIZE); in Connect()
165 VolumeControlDevice* device = in OnGattConnected() local
167 if (!device) { in OnGattConnected()
174 device_cleanup_helper(device, device->connecting_actively); in OnGattConnected()
178 device->connection_id = connection_id; in OnGattConnected()
185 if (device->IsEncryptionEnabled()) { in OnGattConnected()
190 if (!device->EnableEncryption()) { in OnGattConnected()
192 device->Disconnect(gatt_if_); in OnGattConnected()
197 VolumeControlDevice* device = in OnEncryptionComplete() local
199 if (!device) { in OnEncryptionComplete()
209 device_cleanup_helper(device, device->connecting_actively); in OnEncryptionComplete()
215 if (device->HasHandles()) { in OnEncryptionComplete()
216 device->EnqueueInitialRequests(gatt_if_, chrc_read_callback_static, in OnEncryptionComplete()
220 BTA_GATTC_ServiceSearchRequest(device->connection_id, kVolumeControlUuid); in OnEncryptionComplete()
224 void ClearDeviceInformationAndStartSearch(VolumeControlDevice* device) { in ClearDeviceInformationAndStartSearch() argument
225 if (!device) { in ClearDeviceInformationAndStartSearch()
230 log::info("address={}", device->address); in ClearDeviceInformationAndStartSearch()
231 if (device->known_service_handles_ == false) { in ClearDeviceInformationAndStartSearch()
236 std::vector<RawAddress> devices = {device->address}; in ClearDeviceInformationAndStartSearch()
237 device->DeregisterNotifications(gatt_if_); in ClearDeviceInformationAndStartSearch()
241 device->ResetHandles(); in ClearDeviceInformationAndStartSearch()
242 BTA_GATTC_ServiceSearchRequest(device->connection_id, kVolumeControlUuid); in ClearDeviceInformationAndStartSearch()
246 VolumeControlDevice* device = in OnServiceChangeEvent() local
248 if (!device) { in OnServiceChangeEvent()
253 ClearDeviceInformationAndStartSearch(device); in OnServiceChangeEvent()
257 VolumeControlDevice* device = in OnServiceDiscDoneEvent() local
259 if (!device) { in OnServiceDiscDoneEvent()
264 if (device->known_service_handles_ == false) { in OnServiceDiscDoneEvent()
265 BTA_GATTC_ServiceSearchRequest(device->connection_id, kVolumeControlUuid); in OnServiceDiscDoneEvent()
270 VolumeControlDevice* device = in OnServiceSearchComplete() local
272 if (!device) { in OnServiceSearchComplete()
279 if (device->IsReady()) return; in OnServiceSearchComplete()
284 device_cleanup_helper(device, device->connecting_actively); in OnServiceSearchComplete()
288 if (!device->IsEncryptionEnabled()) { in OnServiceSearchComplete()
293 bool success = device->UpdateHandles(); in OnServiceSearchComplete()
296 device_cleanup_helper(device, device->connecting_actively); in OnServiceSearchComplete()
300 device->EnqueueInitialRequests(gatt_if_, chrc_read_callback_static, in OnServiceSearchComplete()
308 VolumeControlDevice* device = volume_control_devices_.FindByConnId(conn_id); in OnCharacteristicValueChanged() local
309 if (!device) { in OnCharacteristicValueChanged()
317 log::info("Database out of sync for {}", device->address); in OnCharacteristicValueChanged()
318 ClearDeviceInformationAndStartSearch(device); in OnCharacteristicValueChanged()
323 if (handle == device->volume_state_handle) { in OnCharacteristicValueChanged()
324 OnVolumeControlStateReadOrNotified(device, len, value, is_notification); in OnCharacteristicValueChanged()
325 verify_device_ready(device, handle); in OnCharacteristicValueChanged()
328 if (handle == device->volume_flags_handle) { in OnCharacteristicValueChanged()
329 OnVolumeControlFlagsChanged(device, len, value); in OnCharacteristicValueChanged()
330 verify_device_ready(device, handle); in OnCharacteristicValueChanged()
338 device->audio_offsets.FindByServiceHandle(service->handle); in OnCharacteristicValueChanged()
341 OnExtAudioOutStateChanged(device, offset, len, value); in OnCharacteristicValueChanged()
343 OnExtAudioOutLocationChanged(device, offset, len, value); in OnCharacteristicValueChanged()
345 OnOffsetOutputDescChanged(device, offset, len, value); in OnCharacteristicValueChanged()
351 verify_device_ready(device, handle); in OnCharacteristicValueChanged()
370 void HandleAutonomusVolumeChange(VolumeControlDevice* device, in HandleAutonomusVolumeChange() argument
372 log::debug("{}, is volume change: {}, is mute change: {}", device->address, in HandleAutonomusVolumeChange()
383 callbacks_->OnVolumeStateChanged(device->address, device->volume, in HandleAutonomusVolumeChange()
384 device->mute, true); in HandleAutonomusVolumeChange()
389 csis_api->GetGroupId(device->address, le_audio::uuid::kCapServiceUuid); in HandleAutonomusVolumeChange()
391 log::warn("No group for device {}", device->address); in HandleAutonomusVolumeChange()
392 callbacks_->OnVolumeStateChanged(device->address, device->volume, in HandleAutonomusVolumeChange()
393 device->mute, true); in HandleAutonomusVolumeChange()
400 if (!dev || !dev->IsConnected() || (dev->address == device->address)) { in HandleAutonomusVolumeChange()
409 callbacks_->OnGroupVolumeStateChanged(group_id, device->volume, in HandleAutonomusVolumeChange()
410 device->mute, true); in HandleAutonomusVolumeChange()
415 std::vector<uint8_t> arg({device->volume}); in HandleAutonomusVolumeChange()
423 device->mute ? kControlPointOpcodeMute : kControlPointOpcodeUnmute; in HandleAutonomusVolumeChange()
430 void OnVolumeControlStateReadOrNotified(VolumeControlDevice* device, in OnVolumeControlStateReadOrNotified() argument
443 STREAM_TO_UINT8(device->change_counter, pp); in OnVolumeControlStateReadOrNotified()
445 bool is_volume_change = (device->volume != vol); in OnVolumeControlStateReadOrNotified()
446 device->volume = vol; in OnVolumeControlStateReadOrNotified()
448 bool is_mute_change = (device->mute != mute); in OnVolumeControlStateReadOrNotified()
449 device->mute = mute; in OnVolumeControlStateReadOrNotified()
451 log::info("volume 0x{:x} mute 0x{:x} change_counter 0x{:x}", device->volume, in OnVolumeControlStateReadOrNotified()
452 device->mute, device->change_counter); in OnVolumeControlStateReadOrNotified()
454 if (!device->IsReady()) { in OnVolumeControlStateReadOrNotified()
455 log::info("Device: {} is not ready yet.", device->address); in OnVolumeControlStateReadOrNotified()
461 callbacks_->OnVolumeStateChanged(device->address, device->volume, in OnVolumeControlStateReadOrNotified()
462 device->mute, false); in OnVolumeControlStateReadOrNotified()
466 auto addr = device->address; in OnVolumeControlStateReadOrNotified()
475 device->address); in OnVolumeControlStateReadOrNotified()
476 HandleAutonomusVolumeChange(device, is_volume_change, is_mute_change); in OnVolumeControlStateReadOrNotified()
481 auto it = find(op->devices_.begin(), op->devices_.end(), device->address); in OnVolumeControlStateReadOrNotified()
490 callbacks_->OnGroupVolumeStateChanged(op->group_id_, device->volume, in OnVolumeControlStateReadOrNotified()
491 device->mute, op->is_autonomous_); in OnVolumeControlStateReadOrNotified()
495 callbacks_->OnVolumeStateChanged(device->address, device->volume, in OnVolumeControlStateReadOrNotified()
496 device->mute, false); in OnVolumeControlStateReadOrNotified()
503 void OnVolumeControlFlagsChanged(VolumeControlDevice* device, uint16_t len, in OnVolumeControlFlagsChanged() argument
505 device->flags = *value; in OnVolumeControlFlagsChanged()
507 log::info("flags 0x{:x}", device->flags); in OnVolumeControlFlagsChanged()
510 void OnExtAudioOutStateChanged(VolumeControlDevice* device, in OnExtAudioOutStateChanged() argument
526 if (!device->IsReady()) { in OnExtAudioOutStateChanged()
527 log::info("Device: {} is not ready yet.", device->address); in OnExtAudioOutStateChanged()
531 callbacks_->OnExtAudioOutVolumeOffsetChanged(device->address, offset->id, in OnExtAudioOutStateChanged()
535 void OnExtAudioOutLocationChanged(VolumeControlDevice* device, in OnExtAudioOutLocationChanged() argument
549 if (!device->IsReady()) { in OnExtAudioOutLocationChanged()
550 log::info("Device: {} is not ready yet.", device->address); in OnExtAudioOutLocationChanged()
554 callbacks_->OnExtAudioOutLocationChanged(device->address, offset->id, in OnExtAudioOutLocationChanged()
560 VolumeControlDevice* device = in OnExtAudioOutCPWrite() local
562 if (!device) { in OnExtAudioOutCPWrite()
574 void OnOffsetOutputDescChanged(VolumeControlDevice* device, in OnOffsetOutputDescChanged() argument
582 if (!device->IsReady()) { in OnOffsetOutputDescChanged()
583 log::info("Device: {} is not ready yet.", device->address); in OnOffsetOutputDescChanged()
587 callbacks_->OnExtAudioOutDescriptionChanged(device->address, offset->id, in OnOffsetOutputDescChanged()
594 VolumeControlDevice* device = in OnGattWriteCcc() local
596 if (!device) { in OnGattWriteCcc()
605 device->address, connection_id); in OnGattWriteCcc()
606 ClearDeviceInformationAndStartSearch(device); in OnGattWriteCcc()
611 device_cleanup_helper(device, true); in OnGattWriteCcc()
617 device->address); in OnGattWriteCcc()
619 verify_device_ready(device, handle); in OnGattWriteCcc()
641 VolumeControlDevice* device = in Disconnect() local
643 if (!device) { in Disconnect()
649 log::info("GAP_EVT_CONN_CLOSED: {}", device->address); in Disconnect()
650 device->connecting_actively = false; in Disconnect()
651 device_cleanup_helper(device, true); in Disconnect()
666 VolumeControlDevice* device = in OnGattDisconnected() local
668 if (!device) { in OnGattDisconnected()
674 if (!device->IsConnected()) { in OnGattDisconnected()
684 bool notify = device->IsReady() || device->connecting_actively; in OnGattDisconnected()
685 device_cleanup_helper(device, notify); in OnGattDisconnected()
688 device->connecting_actively) { in OnGattDisconnected()
772 VolumeControlDevice* device = in OnWriteControlResponse() local
774 if (!device) { in OnWriteControlResponse()
786 RemoveDeviceFromOperationList(device->address, PTR_TO_INT(data)); in OnWriteControlResponse()
789 log::info("Database out of sync for {}", device->address); in OnWriteControlResponse()
790 ClearDeviceInformationAndStartSearch(device); in OnWriteControlResponse()
1030 VolumeControlDevice* device = in GetExtAudioOutVolumeOffset() local
1032 if (!device) { in GetExtAudioOutVolumeOffset()
1037 device->GetExtAudioOutVolumeOffset(ext_output_id, chrc_read_callback_static, in GetExtAudioOutVolumeOffset()
1053 VolumeControlDevice* device = in GetExtAudioOutLocation() local
1055 if (!device) { in GetExtAudioOutLocation()
1060 device->GetExtAudioOutLocation(ext_output_id, chrc_read_callback_static, in GetExtAudioOutLocation()
1066 VolumeControlDevice* device = in SetExtAudioOutLocation() local
1068 if (!device) { in SetExtAudioOutLocation()
1073 device->SetExtAudioOutLocation(ext_output_id, location); in SetExtAudioOutLocation()
1078 VolumeControlDevice* device = in GetExtAudioOutDescription() local
1080 if (!device) { in GetExtAudioOutDescription()
1085 device->GetExtAudioOutDescription(ext_output_id, chrc_read_callback_static, in GetExtAudioOutDescription()
1092 VolumeControlDevice* device = in SetExtAudioOutDescription() local
1094 if (!device) { in SetExtAudioOutDescription()
1099 device->SetExtAudioOutDescription(ext_output_id, descr); in SetExtAudioOutDescription()
1121 void verify_device_ready(VolumeControlDevice* device, uint16_t handle) { in verify_device_ready() argument
1122 if (device->IsReady()) return; in verify_device_ready()
1126 if (device->VerifyReady(handle)) { in verify_device_ready()
1129 callbacks_->OnDeviceAvailable(device->address, in verify_device_ready()
1130 device->audio_offsets.Size()); in verify_device_ready()
1132 device->address); in verify_device_ready()
1135 callbacks_->OnVolumeStateChanged(device->address, device->volume, in verify_device_ready()
1136 device->mute, false); in verify_device_ready()
1138 for (auto const& offset : device->audio_offsets.volume_offsets) { in verify_device_ready()
1139 callbacks_->OnExtAudioOutVolumeOffsetChanged(device->address, offset.id, in verify_device_ready()
1143 device->EnqueueRemainingRequests(gatt_if_, chrc_read_callback_static, in verify_device_ready()
1148 void device_cleanup_helper(VolumeControlDevice* device, bool notify) { in device_cleanup_helper() argument
1149 device->Disconnect(gatt_if_); in device_cleanup_helper()
1151 RemoveDeviceFromOperationList(device->address); in device_cleanup_helper()
1155 device->address); in device_cleanup_helper()
1177 VolumeControlDevice* device = in ext_audio_out_control_point_helper() local
1179 if (!device) { in ext_audio_out_control_point_helper()
1183 device->ExtAudioOutControlPointOperation( in ext_audio_out_control_point_helper()