Loading system/audio_bluetooth_hw/device_port_proxy.cc +17 −4 Original line number Diff line number Diff line Loading @@ -70,12 +70,23 @@ audio_channel_mask_t InputChannelModeToAudioFormat(ChannelMode channel_mode) { } } audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample) { audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample, const SessionType& session_type) { switch (bits_per_sample) { case 16: return AUDIO_FORMAT_PCM_16_BIT; case 24: /* Now we use knowledge that Classic sessions used packed, and LE Audio * LC3 encoder uses unpacked as input. This should be passed as parameter * from BT stack through AIDL, but it would require new interface version, * so sticking with this workaround for now. */ if (session_type == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type == SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH) { return AUDIO_FORMAT_PCM_24_BIT_PACKED; } else { return AUDIO_FORMAT_PCM_8_24_BIT; } case 32: return AUDIO_FORMAT_PCM_32_BIT; default: Loading Loading @@ -354,7 +365,8 @@ bool BluetoothAudioPortAidlOut::LoadAudioConfig( (is_stereo_to_mono_ ? AUDIO_CHANNEL_OUT_STEREO : OutputChannelModeToAudioFormat(pcm_cfg.channelMode)); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_); return true; } Loading Loading @@ -388,7 +400,8 @@ bool BluetoothAudioPortAidlIn::LoadAudioConfig( audio_cfg->sample_rate = pcm_cfg.sampleRateHz; audio_cfg->channel_mask = InputChannelModeToAudioFormat(pcm_cfg.channelMode); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_); return true; } Loading system/audio_bluetooth_hw/stream_apis.cc +3 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,9 @@ static char* out_get_parameters(const struct audio_stream* stream, if (audio_cfg.format == AUDIO_FORMAT_PCM_24_BIT_PACKED) { param = "AUDIO_FORMAT_PCM_24_BIT_PACKED"; } if (audio_cfg.format == AUDIO_FORMAT_PCM_8_24_BIT) { param = "AUDIO_FORMAT_PCM_8_24_BIT"; } if (audio_cfg.format == AUDIO_FORMAT_PCM_32_BIT) { param = "AUDIO_FORMAT_PCM_32_BIT"; } Loading system/bta/le_audio/client_audio.cc +6 −2 Original line number Diff line number Diff line Loading @@ -82,10 +82,14 @@ bool LeAudioClientAudioSource::SinkOnResumeReq(bool start_media_task) { } void LeAudioClientAudioSource::SendAudioData() { // 24 bit audio is aligned to 32bit int bytes_per_sample = (source_codec_config_.bits_per_sample == 24) ? 4 : (source_codec_config_.bits_per_sample / 8); uint32_t bytes_per_tick = (source_codec_config_.num_channels * source_codec_config_.sample_rate * source_codec_config_.data_interval_us / 1000 * (source_codec_config_.bits_per_sample / 8)) / source_codec_config_.data_interval_us / 1000 * bytes_per_sample) / 1000; std::vector<uint8_t> data(bytes_per_tick); Loading system/bta/le_audio/client_audio_test.cc +2 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,8 @@ TEST_F(LeAudioClientAudioTest, std::future_status::ready); // Check agains expected payload size const uint32_t channel_bytes_per_sample = (24 /*bps*/ / 8); // 24 bit audio stream is sent as unpacked, each sample takes 4 bytes. const uint32_t channel_bytes_per_sample = 4; const uint32_t channel_bytes_per_10ms_at_16000Hz = ((10ms).count() * channel_bytes_per_sample * 16000 /*Hz*/) / (1000ms).count(); Loading Loading
system/audio_bluetooth_hw/device_port_proxy.cc +17 −4 Original line number Diff line number Diff line Loading @@ -70,12 +70,23 @@ audio_channel_mask_t InputChannelModeToAudioFormat(ChannelMode channel_mode) { } } audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample) { audio_format_t BitsPerSampleToAudioFormat(uint8_t bits_per_sample, const SessionType& session_type) { switch (bits_per_sample) { case 16: return AUDIO_FORMAT_PCM_16_BIT; case 24: /* Now we use knowledge that Classic sessions used packed, and LE Audio * LC3 encoder uses unpacked as input. This should be passed as parameter * from BT stack through AIDL, but it would require new interface version, * so sticking with this workaround for now. */ if (session_type == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type == SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH) { return AUDIO_FORMAT_PCM_24_BIT_PACKED; } else { return AUDIO_FORMAT_PCM_8_24_BIT; } case 32: return AUDIO_FORMAT_PCM_32_BIT; default: Loading Loading @@ -354,7 +365,8 @@ bool BluetoothAudioPortAidlOut::LoadAudioConfig( (is_stereo_to_mono_ ? AUDIO_CHANNEL_OUT_STEREO : OutputChannelModeToAudioFormat(pcm_cfg.channelMode)); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_); return true; } Loading Loading @@ -388,7 +400,8 @@ bool BluetoothAudioPortAidlIn::LoadAudioConfig( audio_cfg->sample_rate = pcm_cfg.sampleRateHz; audio_cfg->channel_mask = InputChannelModeToAudioFormat(pcm_cfg.channelMode); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample); audio_cfg->format = BitsPerSampleToAudioFormat(pcm_cfg.bitsPerSample, session_type_); return true; } Loading
system/audio_bluetooth_hw/stream_apis.cc +3 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,9 @@ static char* out_get_parameters(const struct audio_stream* stream, if (audio_cfg.format == AUDIO_FORMAT_PCM_24_BIT_PACKED) { param = "AUDIO_FORMAT_PCM_24_BIT_PACKED"; } if (audio_cfg.format == AUDIO_FORMAT_PCM_8_24_BIT) { param = "AUDIO_FORMAT_PCM_8_24_BIT"; } if (audio_cfg.format == AUDIO_FORMAT_PCM_32_BIT) { param = "AUDIO_FORMAT_PCM_32_BIT"; } Loading
system/bta/le_audio/client_audio.cc +6 −2 Original line number Diff line number Diff line Loading @@ -82,10 +82,14 @@ bool LeAudioClientAudioSource::SinkOnResumeReq(bool start_media_task) { } void LeAudioClientAudioSource::SendAudioData() { // 24 bit audio is aligned to 32bit int bytes_per_sample = (source_codec_config_.bits_per_sample == 24) ? 4 : (source_codec_config_.bits_per_sample / 8); uint32_t bytes_per_tick = (source_codec_config_.num_channels * source_codec_config_.sample_rate * source_codec_config_.data_interval_us / 1000 * (source_codec_config_.bits_per_sample / 8)) / source_codec_config_.data_interval_us / 1000 * bytes_per_sample) / 1000; std::vector<uint8_t> data(bytes_per_tick); Loading
system/bta/le_audio/client_audio_test.cc +2 −1 Original line number Diff line number Diff line Loading @@ -506,7 +506,8 @@ TEST_F(LeAudioClientAudioTest, std::future_status::ready); // Check agains expected payload size const uint32_t channel_bytes_per_sample = (24 /*bps*/ / 8); // 24 bit audio stream is sent as unpacked, each sample takes 4 bytes. const uint32_t channel_bytes_per_sample = 4; const uint32_t channel_bytes_per_10ms_at_16000Hz = ((10ms).count() * channel_bytes_per_sample * 16000 /*Hz*/) / (1000ms).count(); Loading