Loading system/audio_bluetooth_hw/audio_bluetooth_hw.cc +57 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,59 @@ static int adev_get_mic_mute(const struct audio_hw_device* dev, bool* state) { return -ENOSYS; } static int adev_create_audio_patch(struct audio_hw_device* device, unsigned int num_sources, const struct audio_port_config* sources, unsigned int num_sinks, const struct audio_port_config* sinks, audio_patch_handle_t* handle) { if (device == nullptr || sources == nullptr || sinks == nullptr || handle == nullptr || num_sources != 1 || num_sinks == 0 || num_sinks > AUDIO_PATCH_PORTS_MAX) { return -EINVAL; } if (sources[0].type == AUDIO_PORT_TYPE_DEVICE) { if (num_sinks != 1 || sinks[0].type != AUDIO_PORT_TYPE_MIX) { return -EINVAL; } } else if (sources[0].type == AUDIO_PORT_TYPE_MIX) { for (unsigned int i = 0; i < num_sinks; i++) { if (sinks[i].type != AUDIO_PORT_TYPE_DEVICE) { return -EINVAL; } } } else { return -EINVAL; } auto* bluetooth_device = reinterpret_cast<BluetoothAudioDevice*>(device); std::lock_guard<std::mutex> guard(bluetooth_device->mutex_); if (*handle == AUDIO_PATCH_HANDLE_NONE) { *handle = ++bluetooth_device->next_unique_id; } LOG(INFO) << __func__ << ": device=" << std::hex << sinks[0].ext.device.type << " handle: " << *handle; return 0; } static int adev_release_audio_patch(struct audio_hw_device* device, audio_patch_handle_t patch_handle) { if (device == nullptr) { return -EINVAL; } LOG(INFO) << __func__ << ": patch_handle=" << patch_handle; return 0; } static int adev_get_audio_port(struct audio_hw_device* device, struct audio_port* port) { if (device == nullptr || port == nullptr) { return -EINVAL; } return -ENOSYS; } static int adev_dump(const audio_hw_device_t* device, int fd) { return 0; } static int adev_close(hw_device_t* device) { Loading @@ -117,7 +170,7 @@ static int adev_open(const hw_module_t* module, const char* name, if (!adev) return -ENOMEM; adev->common.tag = HARDWARE_DEVICE_TAG; adev->common.version = AUDIO_DEVICE_API_VERSION_2_0; adev->common.version = AUDIO_DEVICE_API_VERSION_3_0; adev->common.module = (struct hw_module_t*)module; adev->common.close = adev_close; Loading @@ -138,6 +191,9 @@ static int adev_open(const hw_module_t* module, const char* name, adev->dump = adev_dump; adev->set_master_mute = adev_set_master_mute; adev->get_master_mute = adev_get_master_mute; adev->create_audio_patch = adev_create_audio_patch; adev->release_audio_patch = adev_release_audio_patch; adev->get_audio_port = adev_get_audio_port; *device = &adev->common; return 0; Loading system/audio_bluetooth_hw/stream_apis.h +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ struct BluetoothAudioDevice { std::mutex mutex_; std::list<BluetoothStreamOut*> opened_stream_outs_ = std::list<BluetoothStreamOut*>(0); uint32_t next_unique_id = 1; }; struct BluetoothStreamIn { Loading Loading
system/audio_bluetooth_hw/audio_bluetooth_hw.cc +57 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,59 @@ static int adev_get_mic_mute(const struct audio_hw_device* dev, bool* state) { return -ENOSYS; } static int adev_create_audio_patch(struct audio_hw_device* device, unsigned int num_sources, const struct audio_port_config* sources, unsigned int num_sinks, const struct audio_port_config* sinks, audio_patch_handle_t* handle) { if (device == nullptr || sources == nullptr || sinks == nullptr || handle == nullptr || num_sources != 1 || num_sinks == 0 || num_sinks > AUDIO_PATCH_PORTS_MAX) { return -EINVAL; } if (sources[0].type == AUDIO_PORT_TYPE_DEVICE) { if (num_sinks != 1 || sinks[0].type != AUDIO_PORT_TYPE_MIX) { return -EINVAL; } } else if (sources[0].type == AUDIO_PORT_TYPE_MIX) { for (unsigned int i = 0; i < num_sinks; i++) { if (sinks[i].type != AUDIO_PORT_TYPE_DEVICE) { return -EINVAL; } } } else { return -EINVAL; } auto* bluetooth_device = reinterpret_cast<BluetoothAudioDevice*>(device); std::lock_guard<std::mutex> guard(bluetooth_device->mutex_); if (*handle == AUDIO_PATCH_HANDLE_NONE) { *handle = ++bluetooth_device->next_unique_id; } LOG(INFO) << __func__ << ": device=" << std::hex << sinks[0].ext.device.type << " handle: " << *handle; return 0; } static int adev_release_audio_patch(struct audio_hw_device* device, audio_patch_handle_t patch_handle) { if (device == nullptr) { return -EINVAL; } LOG(INFO) << __func__ << ": patch_handle=" << patch_handle; return 0; } static int adev_get_audio_port(struct audio_hw_device* device, struct audio_port* port) { if (device == nullptr || port == nullptr) { return -EINVAL; } return -ENOSYS; } static int adev_dump(const audio_hw_device_t* device, int fd) { return 0; } static int adev_close(hw_device_t* device) { Loading @@ -117,7 +170,7 @@ static int adev_open(const hw_module_t* module, const char* name, if (!adev) return -ENOMEM; adev->common.tag = HARDWARE_DEVICE_TAG; adev->common.version = AUDIO_DEVICE_API_VERSION_2_0; adev->common.version = AUDIO_DEVICE_API_VERSION_3_0; adev->common.module = (struct hw_module_t*)module; adev->common.close = adev_close; Loading @@ -138,6 +191,9 @@ static int adev_open(const hw_module_t* module, const char* name, adev->dump = adev_dump; adev->set_master_mute = adev_set_master_mute; adev->get_master_mute = adev_get_master_mute; adev->create_audio_patch = adev_create_audio_patch; adev->release_audio_patch = adev_release_audio_patch; adev->get_audio_port = adev_get_audio_port; *device = &adev->common; return 0; Loading
system/audio_bluetooth_hw/stream_apis.h +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ struct BluetoothAudioDevice { std::mutex mutex_; std::list<BluetoothStreamOut*> opened_stream_outs_ = std::list<BluetoothStreamOut*>(0); uint32_t next_unique_id = 1; }; struct BluetoothStreamIn { Loading