Loading system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc +62 −23 Original line number Diff line number Diff line Loading @@ -23,11 +23,23 @@ #include <vector> #include "a2dp_provider_info.h" #include "a2dp_transport.h" #include "audio_aidl_interfaces.h" #include "client_interface_aidl.h" #include "codec_status_aidl.h" #include "transport_instance.h" typedef enum { A2DP_CTRL_CMD_NONE, A2DP_CTRL_CMD_CHECK_READY, A2DP_CTRL_CMD_START, A2DP_CTRL_CMD_STOP, A2DP_CTRL_CMD_SUSPEND, A2DP_CTRL_GET_INPUT_AUDIO_CONFIG, A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; namespace fmt { template <> struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {}; Loading @@ -42,6 +54,47 @@ namespace audio { namespace aidl { namespace a2dp { namespace { using ::bluetooth::audio::a2dp::BluetoothAudioStatus; using ::bluetooth::audio::aidl::a2dp::LatencyMode; // Provide call-in APIs for the Bluetooth Audio HAL class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothTransportInstance { public: A2dpTransport(SessionType sessionType); BluetoothAudioStatus StartRequest(bool is_low_latency) override; BluetoothAudioStatus SuspendRequest() override; void StopRequest() override; void SetLatencyMode(LatencyMode latency_mode) override; bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read, timespec* data_position) override; tA2DP_CTRL_CMD GetPendingCmd() const; void ResetPendingCmd(); void ResetPresentationPosition(); void LogBytesRead(size_t bytes_read) override; // delay reports from AVDTP is based on 1/10 ms (100us) void SetRemoteDelay(uint16_t delay_report); private: static tA2DP_CTRL_CMD a2dp_pending_cmd_; static uint16_t remote_delay_report_; uint64_t total_bytes_read_; timespec data_position_; }; } // namespace using ::bluetooth::audio::a2dp::BluetoothAudioPort; using ::bluetooth::audio::a2dp::BluetoothAudioStatus; Loading @@ -57,7 +110,7 @@ using ::aidl::android::hardware::bluetooth::audio::CodecConfiguration; using ::aidl::android::hardware::bluetooth::audio::PcmConfiguration; using ::aidl::android::hardware::bluetooth::audio::SessionType; using ::bluetooth::audio::aidl::a2dp::BluetoothAudioSinkClientInterface; using ::bluetooth::audio::aidl::a2dp::BluetoothAudioClientInterface; using ::bluetooth::audio::aidl::a2dp::codec::A2dpAacToHalConfig; using ::bluetooth::audio::aidl::a2dp::codec::A2dpAptxToHalConfig; using ::bluetooth::audio::aidl::a2dp::codec::A2dpCodecToHalBitsPerSample; Loading @@ -78,7 +131,7 @@ tA2DP_CTRL_CMD A2dpTransport::a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; uint16_t A2dpTransport::remote_delay_report_ = 0; A2dpTransport::A2dpTransport(SessionType sessionType) : IBluetoothSinkTransportInstance(sessionType, (AudioConfiguration){}), : IBluetoothTransportInstance(sessionType, (AudioConfiguration){}), total_bytes_read_(0), data_position_({}) { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; Loading Loading @@ -151,20 +204,6 @@ bool A2dpTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns, return true; } void A2dpTransport::SourceMetadataChanged(const source_metadata_v7_t& source_metadata) { auto track_count = source_metadata.track_count; auto tracks = source_metadata.tracks; log::verbose("{} track(s) received", track_count); while (track_count) { log::verbose("usage={}, content_type={}, gain={}", tracks->base.usage, tracks->base.content_type, tracks->base.gain); --track_count; ++tracks; } } void A2dpTransport::SinkMetadataChanged(const sink_metadata_v7_t&) {} tA2DP_CTRL_CMD A2dpTransport::GetPendingCmd() const { return a2dp_pending_cmd_; } void A2dpTransport::ResetPendingCmd() { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; } Loading Loading @@ -192,9 +231,9 @@ void A2dpTransport::LogBytesRead(size_t bytes_read) { void A2dpTransport::SetRemoteDelay(uint16_t delay_report) { remote_delay_report_ = delay_report; } // Common interface to call-out into Bluetooth Audio HAL BluetoothAudioSinkClientInterface* software_hal_interface = nullptr; BluetoothAudioSinkClientInterface* offloading_hal_interface = nullptr; BluetoothAudioSinkClientInterface* active_hal_interface = nullptr; BluetoothAudioClientInterface* software_hal_interface = nullptr; BluetoothAudioClientInterface* offloading_hal_interface = nullptr; BluetoothAudioClientInterface* active_hal_interface = nullptr; // ProviderInfo for A2DP hardware offload encoding and decoding data paths, // if supported by the HAL and enabled. nullptr if not supported Loading Loading @@ -305,9 +344,9 @@ bool is_hal_offloading() { // Opens the HAL client interface of the specified session type and check // that is is valid. Returns nullptr if the client interface did not open // properly. static BluetoothAudioSinkClientInterface* new_hal_interface(SessionType session_type) { static BluetoothAudioClientInterface* new_hal_interface(SessionType session_type) { auto a2dp_transport = new A2dpTransport(session_type); auto hal_interface = new BluetoothAudioSinkClientInterface(a2dp_transport); auto hal_interface = new BluetoothAudioClientInterface(a2dp_transport); if (hal_interface->IsValid()) { return hal_interface; } else { Loading @@ -319,7 +358,7 @@ static BluetoothAudioSinkClientInterface* new_hal_interface(SessionType session_ } /// Delete the selected HAL client interface. static void delete_hal_interface(BluetoothAudioSinkClientInterface* hal_interface) { static void delete_hal_interface(BluetoothAudioClientInterface* hal_interface) { if (hal_interface == nullptr) { return; } Loading system/audio_hal_interface/aidl/a2dp/a2dp_transport.hdeleted 100644 → 0 +0 −86 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "a2dp_encoding.h" #include "client_interface_aidl.h" typedef enum { A2DP_CTRL_CMD_NONE, A2DP_CTRL_CMD_CHECK_READY, A2DP_CTRL_CMD_START, A2DP_CTRL_CMD_STOP, A2DP_CTRL_CMD_SUSPEND, A2DP_CTRL_GET_INPUT_AUDIO_CONFIG, A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; namespace bluetooth { namespace audio { namespace aidl { namespace a2dp { namespace { using ::bluetooth::audio::a2dp::BluetoothAudioStatus; using ::bluetooth::audio::aidl::a2dp::LatencyMode; // Provide call-in APIs for the Bluetooth Audio HAL class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothSinkTransportInstance { public: A2dpTransport(SessionType sessionType); BluetoothAudioStatus StartRequest(bool is_low_latency) override; BluetoothAudioStatus SuspendRequest() override; void StopRequest() override; void SetLatencyMode(LatencyMode latency_mode) override; bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read, timespec* data_position) override; void SourceMetadataChanged(const source_metadata_v7_t& source_metadata); void SinkMetadataChanged(const sink_metadata_v7_t&) override; tA2DP_CTRL_CMD GetPendingCmd() const; void ResetPendingCmd(); void ResetPresentationPosition(); void LogBytesRead(size_t bytes_read) override; // delay reports from AVDTP is based on 1/10 ms (100us) void SetRemoteDelay(uint16_t delay_report); private: static tA2DP_CTRL_CMD a2dp_pending_cmd_; static uint16_t remote_delay_report_; uint64_t total_bytes_read_; timespec data_position_; }; } // namespace } // namespace a2dp } // namespace aidl } // namespace audio } // namespace bluetooth system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h +1 −7 Original line number Diff line number Diff line Loading @@ -45,16 +45,10 @@ #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h> #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h> #include <aidl/android/hardware/bluetooth/audio/LatencyMode.h> #include <aidl/android/hardware/bluetooth/audio/Lc3Capabilities.h> #include <aidl/android/hardware/bluetooth/audio/Lc3Configuration.h> #include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h> #include <aidl/android/hardware/bluetooth/audio/LdacChannelMode.h> #include <aidl/android/hardware/bluetooth/audio/LdacConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LdacQualityIndex.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h> #include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/PresentationPosition.h> Loading system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc +4 −103 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ #include <vector> #include "client_interface_aidl.h" #include "android/binder_ibinder_platform.h" #include "btif/include/btif_common.h" #include "client_interface_aidl.h" #include "common/stop_watch_legacy.h" namespace bluetooth { Loading Loading @@ -96,111 +96,12 @@ ndk::ScopedAStatus BluetoothAudioPortImpl::getPresentationPosition( } ndk::ScopedAStatus BluetoothAudioPortImpl::updateSourceMetadata( const SourceMetadata& source_metadata) { StopWatchLegacy stop_watch(__func__); log::info("{} track(s)", source_metadata.tracks.size()); std::vector<playback_track_metadata_v7> tracks_vec; tracks_vec.reserve(source_metadata.tracks.size()); for (const auto& track : source_metadata.tracks) { auto num_of_tags = track.tags.size(); log::info("metadata tags size: {}", num_of_tags); playback_track_metadata_v7 desc_track = { .base = {.usage = static_cast<audio_usage_t>(track.usage), .content_type = static_cast<audio_content_type_t>(track.contentType), .gain = track.gain}, }; if (num_of_tags != 0) { int copied_size = 0; int max_tags_size = sizeof(desc_track.tags); std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR); for (size_t i = 0; i < num_of_tags - 1; i++) { int string_len = track.tags[i].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); break; } track.tags[i].copy(desc_track.tags + copied_size, string_len, 0); copied_size += string_len; separator.copy(desc_track.tags + copied_size, 1, 0); copied_size += 1; } int string_len = track.tags[num_of_tags - 1].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); } else { track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0); } } else { memset(desc_track.tags, 0, sizeof(desc_track.tags)); } tracks_vec.push_back(desc_track); } const source_metadata_v7_t legacy_source_metadata = {.track_count = tracks_vec.size(), .tracks = tracks_vec.data()}; transport_instance_->SourceMetadataChanged(legacy_source_metadata); const SourceMetadata& /*source_metadata*/) { return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata(const SinkMetadata& sink_metadata) { StopWatchLegacy stop_watch(__func__); log::info("{} track(s)", sink_metadata.tracks.size()); std::vector<record_track_metadata_v7> tracks_vec; tracks_vec.reserve(sink_metadata.tracks.size()); for (const auto& track : sink_metadata.tracks) { auto num_of_tags = track.tags.size(); log::info("metadata tags size: {}", num_of_tags); record_track_metadata_v7 desc_track = { .base = { .source = static_cast<audio_source_t>(track.source), .gain = track.gain, }, }; if (num_of_tags != 0) { int copied_size = 0; int max_tags_size = sizeof(desc_track.tags); std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR); for (size_t i = 0; i < num_of_tags - 1; i++) { int string_len = track.tags[i].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); break; } track.tags[i].copy(desc_track.tags + copied_size, string_len, 0); copied_size += string_len; separator.copy(desc_track.tags + copied_size, 1, 0); copied_size += 1; } int string_len = track.tags[num_of_tags - 1].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); } else { track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0); } } else { memset(desc_track.tags, 0, sizeof(desc_track.tags)); } tracks_vec.push_back(desc_track); } const sink_metadata_v7_t legacy_sink_metadata = {.track_count = tracks_vec.size(), .tracks = tracks_vec.data()}; transport_instance_->SinkMetadataChanged(legacy_sink_metadata); ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata( const SinkMetadata& /*sink_metadata*/) { return ndk::ScopedAStatus::ok(); } Loading system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h +0 −7 Original line number Diff line number Diff line Loading @@ -38,17 +38,11 @@ public: const std::shared_ptr<IBluetoothAudioProvider>& provider); ndk::ScopedAStatus startStream(bool is_low_latency) override; ndk::ScopedAStatus suspendStream() override; ndk::ScopedAStatus stopStream() override; ndk::ScopedAStatus getPresentationPosition(PresentationPosition* _aidl_return) override; ndk::ScopedAStatus updateSourceMetadata(const SourceMetadata& source_metadata) override; ndk::ScopedAStatus updateSinkMetadata(const SinkMetadata& sink_metadata) override; ndk::ScopedAStatus setLatencyMode(LatencyMode latency_mode) override; protected: Loading @@ -60,7 +54,6 @@ protected: private: ndk::ScopedAStatus switchCodec(bool isLowLatency); ndk::SpAIBinder createBinder() override; }; Loading Loading
system/audio_hal_interface/aidl/a2dp/a2dp_encoding_aidl.cc +62 −23 Original line number Diff line number Diff line Loading @@ -23,11 +23,23 @@ #include <vector> #include "a2dp_provider_info.h" #include "a2dp_transport.h" #include "audio_aidl_interfaces.h" #include "client_interface_aidl.h" #include "codec_status_aidl.h" #include "transport_instance.h" typedef enum { A2DP_CTRL_CMD_NONE, A2DP_CTRL_CMD_CHECK_READY, A2DP_CTRL_CMD_START, A2DP_CTRL_CMD_STOP, A2DP_CTRL_CMD_SUSPEND, A2DP_CTRL_GET_INPUT_AUDIO_CONFIG, A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; namespace fmt { template <> struct formatter<tA2DP_CTRL_CMD> : enum_formatter<tA2DP_CTRL_CMD> {}; Loading @@ -42,6 +54,47 @@ namespace audio { namespace aidl { namespace a2dp { namespace { using ::bluetooth::audio::a2dp::BluetoothAudioStatus; using ::bluetooth::audio::aidl::a2dp::LatencyMode; // Provide call-in APIs for the Bluetooth Audio HAL class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothTransportInstance { public: A2dpTransport(SessionType sessionType); BluetoothAudioStatus StartRequest(bool is_low_latency) override; BluetoothAudioStatus SuspendRequest() override; void StopRequest() override; void SetLatencyMode(LatencyMode latency_mode) override; bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read, timespec* data_position) override; tA2DP_CTRL_CMD GetPendingCmd() const; void ResetPendingCmd(); void ResetPresentationPosition(); void LogBytesRead(size_t bytes_read) override; // delay reports from AVDTP is based on 1/10 ms (100us) void SetRemoteDelay(uint16_t delay_report); private: static tA2DP_CTRL_CMD a2dp_pending_cmd_; static uint16_t remote_delay_report_; uint64_t total_bytes_read_; timespec data_position_; }; } // namespace using ::bluetooth::audio::a2dp::BluetoothAudioPort; using ::bluetooth::audio::a2dp::BluetoothAudioStatus; Loading @@ -57,7 +110,7 @@ using ::aidl::android::hardware::bluetooth::audio::CodecConfiguration; using ::aidl::android::hardware::bluetooth::audio::PcmConfiguration; using ::aidl::android::hardware::bluetooth::audio::SessionType; using ::bluetooth::audio::aidl::a2dp::BluetoothAudioSinkClientInterface; using ::bluetooth::audio::aidl::a2dp::BluetoothAudioClientInterface; using ::bluetooth::audio::aidl::a2dp::codec::A2dpAacToHalConfig; using ::bluetooth::audio::aidl::a2dp::codec::A2dpAptxToHalConfig; using ::bluetooth::audio::aidl::a2dp::codec::A2dpCodecToHalBitsPerSample; Loading @@ -78,7 +131,7 @@ tA2DP_CTRL_CMD A2dpTransport::a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; uint16_t A2dpTransport::remote_delay_report_ = 0; A2dpTransport::A2dpTransport(SessionType sessionType) : IBluetoothSinkTransportInstance(sessionType, (AudioConfiguration){}), : IBluetoothTransportInstance(sessionType, (AudioConfiguration){}), total_bytes_read_(0), data_position_({}) { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; Loading Loading @@ -151,20 +204,6 @@ bool A2dpTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns, return true; } void A2dpTransport::SourceMetadataChanged(const source_metadata_v7_t& source_metadata) { auto track_count = source_metadata.track_count; auto tracks = source_metadata.tracks; log::verbose("{} track(s) received", track_count); while (track_count) { log::verbose("usage={}, content_type={}, gain={}", tracks->base.usage, tracks->base.content_type, tracks->base.gain); --track_count; ++tracks; } } void A2dpTransport::SinkMetadataChanged(const sink_metadata_v7_t&) {} tA2DP_CTRL_CMD A2dpTransport::GetPendingCmd() const { return a2dp_pending_cmd_; } void A2dpTransport::ResetPendingCmd() { a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE; } Loading Loading @@ -192,9 +231,9 @@ void A2dpTransport::LogBytesRead(size_t bytes_read) { void A2dpTransport::SetRemoteDelay(uint16_t delay_report) { remote_delay_report_ = delay_report; } // Common interface to call-out into Bluetooth Audio HAL BluetoothAudioSinkClientInterface* software_hal_interface = nullptr; BluetoothAudioSinkClientInterface* offloading_hal_interface = nullptr; BluetoothAudioSinkClientInterface* active_hal_interface = nullptr; BluetoothAudioClientInterface* software_hal_interface = nullptr; BluetoothAudioClientInterface* offloading_hal_interface = nullptr; BluetoothAudioClientInterface* active_hal_interface = nullptr; // ProviderInfo for A2DP hardware offload encoding and decoding data paths, // if supported by the HAL and enabled. nullptr if not supported Loading Loading @@ -305,9 +344,9 @@ bool is_hal_offloading() { // Opens the HAL client interface of the specified session type and check // that is is valid. Returns nullptr if the client interface did not open // properly. static BluetoothAudioSinkClientInterface* new_hal_interface(SessionType session_type) { static BluetoothAudioClientInterface* new_hal_interface(SessionType session_type) { auto a2dp_transport = new A2dpTransport(session_type); auto hal_interface = new BluetoothAudioSinkClientInterface(a2dp_transport); auto hal_interface = new BluetoothAudioClientInterface(a2dp_transport); if (hal_interface->IsValid()) { return hal_interface; } else { Loading @@ -319,7 +358,7 @@ static BluetoothAudioSinkClientInterface* new_hal_interface(SessionType session_ } /// Delete the selected HAL client interface. static void delete_hal_interface(BluetoothAudioSinkClientInterface* hal_interface) { static void delete_hal_interface(BluetoothAudioClientInterface* hal_interface) { if (hal_interface == nullptr) { return; } Loading
system/audio_hal_interface/aidl/a2dp/a2dp_transport.hdeleted 100644 → 0 +0 −86 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "a2dp_encoding.h" #include "client_interface_aidl.h" typedef enum { A2DP_CTRL_CMD_NONE, A2DP_CTRL_CMD_CHECK_READY, A2DP_CTRL_CMD_START, A2DP_CTRL_CMD_STOP, A2DP_CTRL_CMD_SUSPEND, A2DP_CTRL_GET_INPUT_AUDIO_CONFIG, A2DP_CTRL_GET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_SET_OUTPUT_AUDIO_CONFIG, A2DP_CTRL_GET_PRESENTATION_POSITION, } tA2DP_CTRL_CMD; namespace bluetooth { namespace audio { namespace aidl { namespace a2dp { namespace { using ::bluetooth::audio::a2dp::BluetoothAudioStatus; using ::bluetooth::audio::aidl::a2dp::LatencyMode; // Provide call-in APIs for the Bluetooth Audio HAL class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothSinkTransportInstance { public: A2dpTransport(SessionType sessionType); BluetoothAudioStatus StartRequest(bool is_low_latency) override; BluetoothAudioStatus SuspendRequest() override; void StopRequest() override; void SetLatencyMode(LatencyMode latency_mode) override; bool GetPresentationPosition(uint64_t* remote_delay_report_ns, uint64_t* total_bytes_read, timespec* data_position) override; void SourceMetadataChanged(const source_metadata_v7_t& source_metadata); void SinkMetadataChanged(const sink_metadata_v7_t&) override; tA2DP_CTRL_CMD GetPendingCmd() const; void ResetPendingCmd(); void ResetPresentationPosition(); void LogBytesRead(size_t bytes_read) override; // delay reports from AVDTP is based on 1/10 ms (100us) void SetRemoteDelay(uint16_t delay_report); private: static tA2DP_CTRL_CMD a2dp_pending_cmd_; static uint16_t remote_delay_report_; uint64_t total_bytes_read_; timespec data_position_; }; } // namespace } // namespace a2dp } // namespace aidl } // namespace audio } // namespace bluetooth
system/audio_hal_interface/aidl/a2dp/audio_aidl_interfaces.h +1 −7 Original line number Diff line number Diff line Loading @@ -45,16 +45,10 @@ #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h> #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h> #include <aidl/android/hardware/bluetooth/audio/LatencyMode.h> #include <aidl/android/hardware/bluetooth/audio/Lc3Capabilities.h> #include <aidl/android/hardware/bluetooth/audio/Lc3Configuration.h> #include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h> #include <aidl/android/hardware/bluetooth/audio/LdacChannelMode.h> #include <aidl/android/hardware/bluetooth/audio/LdacConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LdacQualityIndex.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecCapabilitiesSetting.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/PcmCapabilities.h> #include <aidl/android/hardware/bluetooth/audio/PcmConfiguration.h> #include <aidl/android/hardware/bluetooth/audio/PresentationPosition.h> Loading
system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.cc +4 −103 Original line number Diff line number Diff line Loading @@ -21,9 +21,9 @@ #include <vector> #include "client_interface_aidl.h" #include "android/binder_ibinder_platform.h" #include "btif/include/btif_common.h" #include "client_interface_aidl.h" #include "common/stop_watch_legacy.h" namespace bluetooth { Loading Loading @@ -96,111 +96,12 @@ ndk::ScopedAStatus BluetoothAudioPortImpl::getPresentationPosition( } ndk::ScopedAStatus BluetoothAudioPortImpl::updateSourceMetadata( const SourceMetadata& source_metadata) { StopWatchLegacy stop_watch(__func__); log::info("{} track(s)", source_metadata.tracks.size()); std::vector<playback_track_metadata_v7> tracks_vec; tracks_vec.reserve(source_metadata.tracks.size()); for (const auto& track : source_metadata.tracks) { auto num_of_tags = track.tags.size(); log::info("metadata tags size: {}", num_of_tags); playback_track_metadata_v7 desc_track = { .base = {.usage = static_cast<audio_usage_t>(track.usage), .content_type = static_cast<audio_content_type_t>(track.contentType), .gain = track.gain}, }; if (num_of_tags != 0) { int copied_size = 0; int max_tags_size = sizeof(desc_track.tags); std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR); for (size_t i = 0; i < num_of_tags - 1; i++) { int string_len = track.tags[i].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); break; } track.tags[i].copy(desc_track.tags + copied_size, string_len, 0); copied_size += string_len; separator.copy(desc_track.tags + copied_size, 1, 0); copied_size += 1; } int string_len = track.tags[num_of_tags - 1].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); } else { track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0); } } else { memset(desc_track.tags, 0, sizeof(desc_track.tags)); } tracks_vec.push_back(desc_track); } const source_metadata_v7_t legacy_source_metadata = {.track_count = tracks_vec.size(), .tracks = tracks_vec.data()}; transport_instance_->SourceMetadataChanged(legacy_source_metadata); const SourceMetadata& /*source_metadata*/) { return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata(const SinkMetadata& sink_metadata) { StopWatchLegacy stop_watch(__func__); log::info("{} track(s)", sink_metadata.tracks.size()); std::vector<record_track_metadata_v7> tracks_vec; tracks_vec.reserve(sink_metadata.tracks.size()); for (const auto& track : sink_metadata.tracks) { auto num_of_tags = track.tags.size(); log::info("metadata tags size: {}", num_of_tags); record_track_metadata_v7 desc_track = { .base = { .source = static_cast<audio_source_t>(track.source), .gain = track.gain, }, }; if (num_of_tags != 0) { int copied_size = 0; int max_tags_size = sizeof(desc_track.tags); std::string separator(1, AUDIO_ATTRIBUTES_TAGS_SEPARATOR); for (size_t i = 0; i < num_of_tags - 1; i++) { int string_len = track.tags[i].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); break; } track.tags[i].copy(desc_track.tags + copied_size, string_len, 0); copied_size += string_len; separator.copy(desc_track.tags + copied_size, 1, 0); copied_size += 1; } int string_len = track.tags[num_of_tags - 1].length(); if ((copied_size >= max_tags_size) || (copied_size + string_len >= max_tags_size)) { log::error("Too many tags, copied size: {}", copied_size); } else { track.tags[num_of_tags - 1].copy(desc_track.tags + copied_size, string_len, 0); } } else { memset(desc_track.tags, 0, sizeof(desc_track.tags)); } tracks_vec.push_back(desc_track); } const sink_metadata_v7_t legacy_sink_metadata = {.track_count = tracks_vec.size(), .tracks = tracks_vec.data()}; transport_instance_->SinkMetadataChanged(legacy_sink_metadata); ndk::ScopedAStatus BluetoothAudioPortImpl::updateSinkMetadata( const SinkMetadata& /*sink_metadata*/) { return ndk::ScopedAStatus::ok(); } Loading
system/audio_hal_interface/aidl/a2dp/bluetooth_audio_port_impl.h +0 −7 Original line number Diff line number Diff line Loading @@ -38,17 +38,11 @@ public: const std::shared_ptr<IBluetoothAudioProvider>& provider); ndk::ScopedAStatus startStream(bool is_low_latency) override; ndk::ScopedAStatus suspendStream() override; ndk::ScopedAStatus stopStream() override; ndk::ScopedAStatus getPresentationPosition(PresentationPosition* _aidl_return) override; ndk::ScopedAStatus updateSourceMetadata(const SourceMetadata& source_metadata) override; ndk::ScopedAStatus updateSinkMetadata(const SinkMetadata& sink_metadata) override; ndk::ScopedAStatus setLatencyMode(LatencyMode latency_mode) override; protected: Loading @@ -60,7 +54,6 @@ protected: private: ndk::ScopedAStatus switchCodec(bool isLowLatency); ndk::SpAIBinder createBinder() override; }; Loading