Loading system/audio_bluetooth_hw/device_port_proxy.cc +20 −21 Original line number Diff line number Diff line Loading @@ -280,6 +280,26 @@ bool BluetoothAudioPort::in_use() const { return (cookie_ != android::bluetooth::audio::kObserversCookieUndefined); } bool BluetoothAudioPort::GetPreferredDataIntervalUs(size_t* interval_us) const { if (!in_use()) { return false; } const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration& hal_audio_cfg = BluetoothAudioSessionControl_2_2::GetAudioConfig(session_type_); if (hal_audio_cfg.getDiscriminator() != ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration:: hidl_discriminator::pcmConfig) { return false; } const ::android::hardware::bluetooth::audio::V2_1::PcmParameters& pcm_cfg = hal_audio_cfg.pcmConfig(); *interval_us = pcm_cfg.dataIntervalUs; return true; } bool BluetoothAudioPortOut::LoadAudioConfig(audio_config_t* audio_cfg) const { if (!in_use()) { LOG(ERROR) << __func__ << ": BluetoothAudioPortOut is not in use"; Loading Loading @@ -319,27 +339,6 @@ bool BluetoothAudioPortOut::LoadAudioConfig(audio_config_t* audio_cfg) const { return true; } bool BluetoothAudioPortOut::GetPreferredDataIntervalUs( size_t* interval_us) const { if (!in_use()) { return false; } const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration& hal_audio_cfg = BluetoothAudioSessionControl_2_2::GetAudioConfig(session_type_); if (hal_audio_cfg.getDiscriminator() != ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration:: hidl_discriminator::pcmConfig) { return false; } const ::android::hardware::bluetooth::audio::V2_1::PcmParameters& pcm_cfg = hal_audio_cfg.pcmConfig(); *interval_us = pcm_cfg.dataIntervalUs; return true; } bool BluetoothAudioPortIn::LoadAudioConfig(audio_config_t* audio_cfg) const { if (!in_use()) { LOG(ERROR) << __func__ << ": BluetoothAudioPortIn is not in use"; Loading system/audio_bluetooth_hw/device_port_proxy.h +2 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,8 @@ class BluetoothAudioPort { session_type_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH; } bool GetPreferredDataIntervalUs(size_t* interval_us) const; protected: uint16_t cookie_; BluetoothStreamState state_; Loading Loading @@ -119,7 +121,6 @@ class BluetoothAudioPortOut : public BluetoothAudioPort { // The audio data path to the Bluetooth stack (Software encoding) size_t WriteData(const void* buffer, size_t bytes) const; bool LoadAudioConfig(audio_config_t* audio_cfg) const; bool GetPreferredDataIntervalUs(size_t* interval_us) const; }; class BluetoothAudioPortIn : public BluetoothAudioPort { Loading system/audio_bluetooth_hw/stream_apis.cc +19 −4 Original line number Diff line number Diff line Loading @@ -755,8 +755,11 @@ int adev_open_output_stream(struct audio_hw_device* dev, bluetooth_device->opened_stream_outs_.push_back(out); } *stream_out = &out->stream_out_; LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState() << ", sample_rate=" << out->sample_rate_ << ", channels=" << StringPrintf("%#x", out->channel_mask_) << ", format=" << out->format_ LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState() << ", sample_rate=" << out->sample_rate_ << ", channels=" << StringPrintf("%#x", out->channel_mask_) << ", format=" << out->format_ << ", preferred_data_interval_us=" << out->preferred_data_interval_us << ", frames=" << out->frames_count_; return 0; } Loading Loading @@ -1197,15 +1200,27 @@ int adev_open_input_stream(struct audio_hw_device* dev, in->channel_mask_ = config->channel_mask; in->format_ = config->format; // frame is number of samples per channel size_t preferred_data_interval_us = kBluetoothDefaultOutputBufferMs * 1000; if (in->bluetooth_input_.GetPreferredDataIntervalUs( &preferred_data_interval_us) && preferred_data_interval_us != 0) { in->preferred_data_interval_us = preferred_data_interval_us; } else { in->preferred_data_interval_us = kBluetoothDefaultOutputBufferMs * 1000; } in->frames_count_ = frame_count(kBluetoothDefaultInputBufferMs, in->sample_rate_); frame_count(in->preferred_data_interval_us, in->sample_rate_); in->frames_presented_ = 0; *stream_in = &in->stream_in_; LOG(INFO) << __func__ << ": state=" << in->bluetooth_input_.GetState() << ", sample_rate=" << in->sample_rate_ << ", channels=" << StringPrintf("%#x", in->channel_mask_) << ", format=" << in->format_ << ", frames=" << in->frames_count_; << ", format=" << in->format_ << ", preferred_data_interval_us=" << in->preferred_data_interval_us << ", frames=" << in->frames_count_; return 0; } Loading system/audio_bluetooth_hw/stream_apis.h +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ struct BluetoothStreamIn { uint32_t sample_rate_; audio_channel_mask_t channel_mask_; audio_format_t format_; size_t preferred_data_interval_us; // frame is the number of samples per channel // frames count per tick size_t frames_count_; Loading Loading
system/audio_bluetooth_hw/device_port_proxy.cc +20 −21 Original line number Diff line number Diff line Loading @@ -280,6 +280,26 @@ bool BluetoothAudioPort::in_use() const { return (cookie_ != android::bluetooth::audio::kObserversCookieUndefined); } bool BluetoothAudioPort::GetPreferredDataIntervalUs(size_t* interval_us) const { if (!in_use()) { return false; } const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration& hal_audio_cfg = BluetoothAudioSessionControl_2_2::GetAudioConfig(session_type_); if (hal_audio_cfg.getDiscriminator() != ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration:: hidl_discriminator::pcmConfig) { return false; } const ::android::hardware::bluetooth::audio::V2_1::PcmParameters& pcm_cfg = hal_audio_cfg.pcmConfig(); *interval_us = pcm_cfg.dataIntervalUs; return true; } bool BluetoothAudioPortOut::LoadAudioConfig(audio_config_t* audio_cfg) const { if (!in_use()) { LOG(ERROR) << __func__ << ": BluetoothAudioPortOut is not in use"; Loading Loading @@ -319,27 +339,6 @@ bool BluetoothAudioPortOut::LoadAudioConfig(audio_config_t* audio_cfg) const { return true; } bool BluetoothAudioPortOut::GetPreferredDataIntervalUs( size_t* interval_us) const { if (!in_use()) { return false; } const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration& hal_audio_cfg = BluetoothAudioSessionControl_2_2::GetAudioConfig(session_type_); if (hal_audio_cfg.getDiscriminator() != ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration:: hidl_discriminator::pcmConfig) { return false; } const ::android::hardware::bluetooth::audio::V2_1::PcmParameters& pcm_cfg = hal_audio_cfg.pcmConfig(); *interval_us = pcm_cfg.dataIntervalUs; return true; } bool BluetoothAudioPortIn::LoadAudioConfig(audio_config_t* audio_cfg) const { if (!in_use()) { LOG(ERROR) << __func__ << ": BluetoothAudioPortIn is not in use"; Loading
system/audio_bluetooth_hw/device_port_proxy.h +2 −1 Original line number Diff line number Diff line Loading @@ -89,6 +89,8 @@ class BluetoothAudioPort { session_type_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH; } bool GetPreferredDataIntervalUs(size_t* interval_us) const; protected: uint16_t cookie_; BluetoothStreamState state_; Loading Loading @@ -119,7 +121,6 @@ class BluetoothAudioPortOut : public BluetoothAudioPort { // The audio data path to the Bluetooth stack (Software encoding) size_t WriteData(const void* buffer, size_t bytes) const; bool LoadAudioConfig(audio_config_t* audio_cfg) const; bool GetPreferredDataIntervalUs(size_t* interval_us) const; }; class BluetoothAudioPortIn : public BluetoothAudioPort { Loading
system/audio_bluetooth_hw/stream_apis.cc +19 −4 Original line number Diff line number Diff line Loading @@ -755,8 +755,11 @@ int adev_open_output_stream(struct audio_hw_device* dev, bluetooth_device->opened_stream_outs_.push_back(out); } *stream_out = &out->stream_out_; LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState() << ", sample_rate=" << out->sample_rate_ << ", channels=" << StringPrintf("%#x", out->channel_mask_) << ", format=" << out->format_ LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState() << ", sample_rate=" << out->sample_rate_ << ", channels=" << StringPrintf("%#x", out->channel_mask_) << ", format=" << out->format_ << ", preferred_data_interval_us=" << out->preferred_data_interval_us << ", frames=" << out->frames_count_; return 0; } Loading Loading @@ -1197,15 +1200,27 @@ int adev_open_input_stream(struct audio_hw_device* dev, in->channel_mask_ = config->channel_mask; in->format_ = config->format; // frame is number of samples per channel size_t preferred_data_interval_us = kBluetoothDefaultOutputBufferMs * 1000; if (in->bluetooth_input_.GetPreferredDataIntervalUs( &preferred_data_interval_us) && preferred_data_interval_us != 0) { in->preferred_data_interval_us = preferred_data_interval_us; } else { in->preferred_data_interval_us = kBluetoothDefaultOutputBufferMs * 1000; } in->frames_count_ = frame_count(kBluetoothDefaultInputBufferMs, in->sample_rate_); frame_count(in->preferred_data_interval_us, in->sample_rate_); in->frames_presented_ = 0; *stream_in = &in->stream_in_; LOG(INFO) << __func__ << ": state=" << in->bluetooth_input_.GetState() << ", sample_rate=" << in->sample_rate_ << ", channels=" << StringPrintf("%#x", in->channel_mask_) << ", format=" << in->format_ << ", frames=" << in->frames_count_; << ", format=" << in->format_ << ", preferred_data_interval_us=" << in->preferred_data_interval_us << ", frames=" << in->frames_count_; return 0; } Loading
system/audio_bluetooth_hw/stream_apis.h +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ struct BluetoothStreamIn { uint32_t sample_rate_; audio_channel_mask_t channel_mask_; audio_format_t format_; size_t preferred_data_interval_us; // frame is the number of samples per channel // frames count per tick size_t frames_count_; Loading