Loading system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc +5 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "audio_hal_client.h" #include <bluetooth/log.h> #include <gmock/gmock.h> #include <gtest/gtest.h> Loading Loading @@ -48,6 +49,8 @@ using bluetooth::le_audio::LeAudioCodecConfiguration; using bluetooth::le_audio::LeAudioSinkAudioHalClient; using bluetooth::le_audio::LeAudioSourceAudioHalClient; using namespace bluetooth; bluetooth::common::MessageLoopThread message_loop_thread("test message loop"); bluetooth::common::MessageLoopThread* get_main_thread() { return &message_loop_thread; Loading @@ -55,7 +58,7 @@ bluetooth::common::MessageLoopThread* get_main_thread() { bt_status_t do_in_main_thread(const base::Location& from_here, base::OnceClosure task) { if (!message_loop_thread.DoInThread(from_here, std::move(task))) { LOG(ERROR) << __func__ << ": failed from " << from_here.ToString(); log::error("failed from {}", from_here.ToString()); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; Loading @@ -71,7 +74,7 @@ static void init_message_loop_thread() { } if (!message_loop_thread.EnableRealTimeScheduling()) LOG(ERROR) << "Unable to set real time scheduling"; log::error("Unable to set real time scheduling"); message_loop_ = message_loop_thread.message_loop(); if (message_loop_ == nullptr) FAIL() << "unable to get message loop."; Loading system/bta/le_audio/audio_hal_client/audio_sink_hal_client.cc +31 −29 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ * ******************************************************************************/ #include <bluetooth/log.h> #include "audio_hal_client.h" #include "audio_hal_interface/le_audio_software.h" #include "bta/le_audio/codec_manager.h" Loading Loading @@ -79,7 +81,7 @@ bool SinkImpl::Acquire() { auto halInterface = audio::le_audio::LeAudioClientInterface::Get(); if (halInterface == nullptr) { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); return false; } Loading @@ -87,7 +89,7 @@ bool SinkImpl::Acquire() { halInterface->GetSource(source_stream_cb, get_main_thread()); if (halSourceInterface_ == nullptr) { LOG_ERROR("Can't get Audio HAL Audio source interface"); log::error("Can't get Audio HAL Audio source interface"); return false; } Loading @@ -98,7 +100,7 @@ bool SinkImpl::Acquire() { void SinkImpl::Release() { if (le_audio_source_hal_state == HAL_UNINITIALIZED) { LOG_WARN("Audio HAL Audio source is not running"); log::warn("Audio HAL Audio source is not running"); return; } Loading @@ -110,7 +112,7 @@ void SinkImpl::Release() { if (halInterface != nullptr) { halInterface->ReleaseSource(halSourceInterface_); } else { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); } le_audio_source_hal_state = HAL_UNINITIALIZED; Loading @@ -120,7 +122,7 @@ void SinkImpl::Release() { bool SinkImpl::OnResumeReq(bool start_media_task) { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -132,13 +134,13 @@ bool SinkImpl::OnResumeReq(bool start_media_task) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } bool SinkImpl::OnSuspendReq() { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -150,13 +152,13 @@ bool SinkImpl::OnSuspendReq() { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } bool SinkImpl::OnMetadataUpdateReq(const sink_metadata_v7_t& sink_metadata) { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -169,7 +171,7 @@ bool SinkImpl::OnMetadataUpdateReq(const sink_metadata_v7_t& sink_metadata) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -177,19 +179,19 @@ bool SinkImpl::Start(const LeAudioCodecConfiguration& codec_configuration, LeAudioSinkAudioHalClient::Callbacks* audioReceiver, DsaModes dsa_modes) { if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface not acquired"); log::error("Audio HAL Audio source interface not acquired"); return false; } if (le_audio_source_hal_state == HAL_STARTED) { LOG_ERROR("Audio HAL Audio source is already in use"); log::error("Audio HAL Audio source is already in use"); return false; } LOG_INFO("bit rate: %d, num channels: %d, sample rate: %d, data interval: %d", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); log::info( "bit rate: {}, num channels: {}, sample rate: {}, data interval: {}", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); audio::le_audio::LeAudioClientInterface::PcmParameters pcmParameters = { .data_interval_us = codec_configuration.data_interval_us, Loading @@ -208,12 +210,12 @@ bool SinkImpl::Start(const LeAudioCodecConfiguration& codec_configuration, void SinkImpl::Stop() { if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface already stopped"); log::error("Audio HAL Audio source interface already stopped"); return; } if (le_audio_source_hal_state != HAL_STARTED) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -227,20 +229,20 @@ void SinkImpl::Stop() { size_t SinkImpl::SendData(uint8_t* data, uint16_t size) { size_t bytes_written; if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface not initialized"); log::error("Audio HAL Audio source interface not initialized"); return 0; } if (le_audio_source_hal_state != HAL_STARTED) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return 0; } /* TODO: What to do if not all data is written ? */ bytes_written = halSourceInterface_->Write(data, size); if (bytes_written != size) { LOG_ERROR( "Not all data is written to source HAL. Bytes written: %zu, total: %d", log::error( "Not all data is written to source HAL. Bytes written: {}, total: {}", bytes_written, size); } Loading @@ -250,7 +252,7 @@ size_t SinkImpl::SendData(uint8_t* data, uint16_t size) { void SinkImpl::ConfirmStreamingRequest() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -265,7 +267,7 @@ void SinkImpl::ConfirmStreamingRequest() { void SinkImpl::SuspendedForReconfiguration() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -276,7 +278,7 @@ void SinkImpl::SuspendedForReconfiguration() { void SinkImpl::ReconfigurationComplete() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -287,7 +289,7 @@ void SinkImpl::ReconfigurationComplete() { void SinkImpl::CancelStreamingRequest() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -302,7 +304,7 @@ void SinkImpl::CancelStreamingRequest() { void SinkImpl::UpdateRemoteDelay(uint16_t remote_delay_ms) { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -314,7 +316,7 @@ void SinkImpl::UpdateAudioConfigToHal( const ::bluetooth::le_audio::offload_config& config) { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -327,7 +329,7 @@ std::unique_ptr<LeAudioSinkAudioHalClient> LeAudioSinkAudioHalClient::AcquireUnicast() { std::unique_ptr<SinkImpl> impl(new SinkImpl()); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Unicast Sink on LE Audio HAL enpoint"); log::error("Could not acquire Unicast Sink on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc +31 −30 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <android_bluetooth_flags.h> #include <base/logging.h> #include <bluetooth/log.h> #include "audio/asrc/asrc_resampler.h" #include "audio_hal_client.h" Loading Loading @@ -121,7 +122,7 @@ bool SourceImpl::Acquire() { /* Get pointer to singleton LE audio client interface */ auto halInterface = audio::le_audio::LeAudioClientInterface::Get(); if (halInterface == nullptr) { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); return false; } Loading @@ -129,7 +130,7 @@ bool SourceImpl::Acquire() { halInterface->GetSink(sink_stream_cb, get_main_thread(), is_broadcaster_); if (halSinkInterface_ == nullptr) { LOG_ERROR("Can't get Audio HAL Audio sink interface"); log::error("Can't get Audio HAL Audio sink interface"); return false; } Loading @@ -140,7 +141,7 @@ bool SourceImpl::Acquire() { void SourceImpl::Release() { if (le_audio_sink_hal_state_ == HAL_UNINITIALIZED) { LOG_WARN("Audio HAL Audio sink is not running"); log::warn("Audio HAL Audio sink is not running"); return; } Loading @@ -154,7 +155,7 @@ void SourceImpl::Release() { if (halInterface != nullptr) { halInterface->ReleaseSink(halSinkInterface_); } else { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); } le_audio_sink_hal_state_ = HAL_UNINITIALIZED; Loading @@ -165,7 +166,7 @@ void SourceImpl::Release() { bool SourceImpl::OnResumeReq(bool start_media_task) { std::lock_guard<std::mutex> guard(audioSourceCallbacksMutex_); if (audioSourceCallbacks_ == nullptr) { LOG_ERROR("audioSourceCallbacks_ not set"); log::error("audioSourceCallbacks_ not set"); return false; } bt_status_t status = do_in_main_thread( Loading @@ -176,13 +177,13 @@ bool SourceImpl::OnResumeReq(bool start_media_task) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } void SourceImpl::SendAudioData() { if (halSinkInterface_ == nullptr) { LOG_ERROR("Audio HAL Audio sink interface not acquired - aborting"); log::error("Audio HAL Audio sink interface not acquired - aborting"); return; } Loading Loading @@ -229,14 +230,14 @@ bool SourceImpl::InitAudioSinkThread() { worker_thread_->StartUp(); if (!worker_thread_->IsRunning()) { LOG_ERROR("Unable to start up the BLE audio sink worker thread"); log::error("Unable to start up the BLE audio sink worker thread"); return false; } /* Schedule the rest of the operations */ if (!worker_thread_->EnableRealTimeScheduling()) { #if defined(__ANDROID__) LOG(FATAL) << __func__ << ", Failed to increase media thread priority"; log::fatal("Failed to increase media thread priority"); #endif } Loading Loading @@ -277,7 +278,7 @@ bool SourceImpl::OnSuspendReq() { } if (audioSourceCallbacks_ == nullptr) { LOG_ERROR("audioSourceCallbacks_ not set"); log::error("audioSourceCallbacks_ not set"); return false; } Loading @@ -289,7 +290,7 @@ bool SourceImpl::OnSuspendReq() { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -297,7 +298,7 @@ bool SourceImpl::OnMetadataUpdateReq( const source_metadata_v7_t& source_metadata, DsaMode dsa_mode) { std::lock_guard<std::mutex> guard(audioSourceCallbacksMutex_); if (audioSourceCallbacks_ == nullptr) { LOG(ERROR) << __func__ << ", audio receiver not started"; log::error("audio receiver not started"); return false; } Loading @@ -311,7 +312,7 @@ bool SourceImpl::OnMetadataUpdateReq( return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -319,19 +320,19 @@ bool SourceImpl::Start(const LeAudioCodecConfiguration& codec_configuration, LeAudioSourceAudioHalClient::Callbacks* audioReceiver, DsaModes dsa_modes) { if (!halSinkInterface_) { LOG_ERROR("Audio HAL Audio sink interface not acquired"); log::error("Audio HAL Audio sink interface not acquired"); return false; } if (le_audio_sink_hal_state_ == HAL_STARTED) { LOG_ERROR("Audio HAL Audio sink is already in use"); log::error("Audio HAL Audio sink is already in use"); return false; } LOG_INFO("bit rate: %d, num channels: %d, sample rate: %d, data interval: %d", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); log::info( "bit rate: {}, num channels: {}, sample rate: {}, data interval: {}", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); sStats.Reset(); Loading @@ -355,12 +356,12 @@ bool SourceImpl::Start(const LeAudioCodecConfiguration& codec_configuration, void SourceImpl::Stop() { if (!halSinkInterface_) { LOG_ERROR("Audio HAL Audio sink interface already stopped"); log::error("Audio HAL Audio sink interface already stopped"); return; } if (le_audio_sink_hal_state_ != HAL_STARTED) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -387,7 +388,7 @@ void SourceImpl::Stop() { void SourceImpl::ConfirmStreamingRequest() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -413,7 +414,7 @@ void SourceImpl::ConfirmStreamingRequest() { void SourceImpl::SuspendedForReconfiguration() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -424,7 +425,7 @@ void SourceImpl::SuspendedForReconfiguration() { void SourceImpl::ReconfigurationComplete() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -435,7 +436,7 @@ void SourceImpl::ReconfigurationComplete() { void SourceImpl::CancelStreamingRequest() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -450,7 +451,7 @@ void SourceImpl::CancelStreamingRequest() { void SourceImpl::UpdateRemoteDelay(uint16_t remote_delay_ms) { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -462,7 +463,7 @@ void SourceImpl::UpdateAudioConfigToHal( const ::bluetooth::le_audio::offload_config& config) { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -473,7 +474,7 @@ void SourceImpl::UpdateAudioConfigToHal( void SourceImpl::UpdateBroadcastAudioConfigToHal( const ::bluetooth::le_audio::broadcast_offload_config& config) { if (halSinkInterface_ == nullptr) { LOG_ERROR("Audio HAL Audio sink interface not acquired"); log::error("Audio HAL Audio sink interface not acquired"); return; } Loading @@ -486,7 +487,7 @@ std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::AcquireUnicast() { std::unique_ptr<SourceImpl> impl(new SourceImpl(false)); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Unicast Source on LE Audio HAL enpoint"); log::error("Could not acquire Unicast Source on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading @@ -499,7 +500,7 @@ std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::AcquireBroadcast() { std::unique_ptr<SourceImpl> impl(new SourceImpl(true)); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Broadcast Source on LE Audio HAL enpoint"); log::error("Could not acquire Broadcast Source on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading system/bta/le_audio/broadcaster/broadcaster.cc +81 −81 File changed.Preview size limit exceeded, changes collapsed. Show changes system/bta/le_audio/broadcaster/broadcaster_test.cc +4 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ * limitations under the License. */ #include <bluetooth/log.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <hardware/audio.h> Loading Loading @@ -53,6 +54,7 @@ using testing::SaveArg; using testing::Test; using namespace bluetooth::le_audio; using namespace bluetooth; using bluetooth::le_audio::DsaMode; using bluetooth::le_audio::LeAudioCodecConfiguration; Loading Loading @@ -90,7 +92,7 @@ bt_status_t do_in_main_thread(const base::Location& from_here, num_async_tasks--; }, std::move(task), std::ref(num_async_tasks)))) { LOG(ERROR) << __func__ << ": failed from " << from_here.ToString(); log::error("failed from {}", from_here.ToString()); return BT_STATUS_FAIL; } num_async_tasks++; Loading @@ -108,7 +110,7 @@ static void init_message_loop_thread() { } if (!message_loop_thread.EnableRealTimeScheduling()) LOG(ERROR) << "Unable to set real time scheduling"; log::error("Unable to set real time scheduling"); message_loop_ = message_loop_thread.message_loop(); if (message_loop_ == nullptr) FAIL() << "unable to get message loop."; Loading Loading
system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc +5 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "audio_hal_client.h" #include <bluetooth/log.h> #include <gmock/gmock.h> #include <gtest/gtest.h> Loading Loading @@ -48,6 +49,8 @@ using bluetooth::le_audio::LeAudioCodecConfiguration; using bluetooth::le_audio::LeAudioSinkAudioHalClient; using bluetooth::le_audio::LeAudioSourceAudioHalClient; using namespace bluetooth; bluetooth::common::MessageLoopThread message_loop_thread("test message loop"); bluetooth::common::MessageLoopThread* get_main_thread() { return &message_loop_thread; Loading @@ -55,7 +58,7 @@ bluetooth::common::MessageLoopThread* get_main_thread() { bt_status_t do_in_main_thread(const base::Location& from_here, base::OnceClosure task) { if (!message_loop_thread.DoInThread(from_here, std::move(task))) { LOG(ERROR) << __func__ << ": failed from " << from_here.ToString(); log::error("failed from {}", from_here.ToString()); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; Loading @@ -71,7 +74,7 @@ static void init_message_loop_thread() { } if (!message_loop_thread.EnableRealTimeScheduling()) LOG(ERROR) << "Unable to set real time scheduling"; log::error("Unable to set real time scheduling"); message_loop_ = message_loop_thread.message_loop(); if (message_loop_ == nullptr) FAIL() << "unable to get message loop."; Loading
system/bta/le_audio/audio_hal_client/audio_sink_hal_client.cc +31 −29 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ * ******************************************************************************/ #include <bluetooth/log.h> #include "audio_hal_client.h" #include "audio_hal_interface/le_audio_software.h" #include "bta/le_audio/codec_manager.h" Loading Loading @@ -79,7 +81,7 @@ bool SinkImpl::Acquire() { auto halInterface = audio::le_audio::LeAudioClientInterface::Get(); if (halInterface == nullptr) { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); return false; } Loading @@ -87,7 +89,7 @@ bool SinkImpl::Acquire() { halInterface->GetSource(source_stream_cb, get_main_thread()); if (halSourceInterface_ == nullptr) { LOG_ERROR("Can't get Audio HAL Audio source interface"); log::error("Can't get Audio HAL Audio source interface"); return false; } Loading @@ -98,7 +100,7 @@ bool SinkImpl::Acquire() { void SinkImpl::Release() { if (le_audio_source_hal_state == HAL_UNINITIALIZED) { LOG_WARN("Audio HAL Audio source is not running"); log::warn("Audio HAL Audio source is not running"); return; } Loading @@ -110,7 +112,7 @@ void SinkImpl::Release() { if (halInterface != nullptr) { halInterface->ReleaseSource(halSourceInterface_); } else { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); } le_audio_source_hal_state = HAL_UNINITIALIZED; Loading @@ -120,7 +122,7 @@ void SinkImpl::Release() { bool SinkImpl::OnResumeReq(bool start_media_task) { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -132,13 +134,13 @@ bool SinkImpl::OnResumeReq(bool start_media_task) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } bool SinkImpl::OnSuspendReq() { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -150,13 +152,13 @@ bool SinkImpl::OnSuspendReq() { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } bool SinkImpl::OnMetadataUpdateReq(const sink_metadata_v7_t& sink_metadata) { if (audioSinkCallbacks_ == nullptr) { LOG_ERROR("audioSinkCallbacks_ not set"); log::error("audioSinkCallbacks_ not set"); return false; } Loading @@ -169,7 +171,7 @@ bool SinkImpl::OnMetadataUpdateReq(const sink_metadata_v7_t& sink_metadata) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -177,19 +179,19 @@ bool SinkImpl::Start(const LeAudioCodecConfiguration& codec_configuration, LeAudioSinkAudioHalClient::Callbacks* audioReceiver, DsaModes dsa_modes) { if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface not acquired"); log::error("Audio HAL Audio source interface not acquired"); return false; } if (le_audio_source_hal_state == HAL_STARTED) { LOG_ERROR("Audio HAL Audio source is already in use"); log::error("Audio HAL Audio source is already in use"); return false; } LOG_INFO("bit rate: %d, num channels: %d, sample rate: %d, data interval: %d", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); log::info( "bit rate: {}, num channels: {}, sample rate: {}, data interval: {}", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); audio::le_audio::LeAudioClientInterface::PcmParameters pcmParameters = { .data_interval_us = codec_configuration.data_interval_us, Loading @@ -208,12 +210,12 @@ bool SinkImpl::Start(const LeAudioCodecConfiguration& codec_configuration, void SinkImpl::Stop() { if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface already stopped"); log::error("Audio HAL Audio source interface already stopped"); return; } if (le_audio_source_hal_state != HAL_STARTED) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -227,20 +229,20 @@ void SinkImpl::Stop() { size_t SinkImpl::SendData(uint8_t* data, uint16_t size) { size_t bytes_written; if (!halSourceInterface_) { LOG_ERROR("Audio HAL Audio source interface not initialized"); log::error("Audio HAL Audio source interface not initialized"); return 0; } if (le_audio_source_hal_state != HAL_STARTED) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return 0; } /* TODO: What to do if not all data is written ? */ bytes_written = halSourceInterface_->Write(data, size); if (bytes_written != size) { LOG_ERROR( "Not all data is written to source HAL. Bytes written: %zu, total: %d", log::error( "Not all data is written to source HAL. Bytes written: {}, total: {}", bytes_written, size); } Loading @@ -250,7 +252,7 @@ size_t SinkImpl::SendData(uint8_t* data, uint16_t size) { void SinkImpl::ConfirmStreamingRequest() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -265,7 +267,7 @@ void SinkImpl::ConfirmStreamingRequest() { void SinkImpl::SuspendedForReconfiguration() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -276,7 +278,7 @@ void SinkImpl::SuspendedForReconfiguration() { void SinkImpl::ReconfigurationComplete() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -287,7 +289,7 @@ void SinkImpl::ReconfigurationComplete() { void SinkImpl::CancelStreamingRequest() { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -302,7 +304,7 @@ void SinkImpl::CancelStreamingRequest() { void SinkImpl::UpdateRemoteDelay(uint16_t remote_delay_ms) { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -314,7 +316,7 @@ void SinkImpl::UpdateAudioConfigToHal( const ::bluetooth::le_audio::offload_config& config) { if ((halSourceInterface_ == nullptr) || (le_audio_source_hal_state != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio source was not started!"); log::error("Audio HAL Audio source was not started!"); return; } Loading @@ -327,7 +329,7 @@ std::unique_ptr<LeAudioSinkAudioHalClient> LeAudioSinkAudioHalClient::AcquireUnicast() { std::unique_ptr<SinkImpl> impl(new SinkImpl()); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Unicast Sink on LE Audio HAL enpoint"); log::error("Could not acquire Unicast Sink on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading
system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc +31 −30 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <android_bluetooth_flags.h> #include <base/logging.h> #include <bluetooth/log.h> #include "audio/asrc/asrc_resampler.h" #include "audio_hal_client.h" Loading Loading @@ -121,7 +122,7 @@ bool SourceImpl::Acquire() { /* Get pointer to singleton LE audio client interface */ auto halInterface = audio::le_audio::LeAudioClientInterface::Get(); if (halInterface == nullptr) { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); return false; } Loading @@ -129,7 +130,7 @@ bool SourceImpl::Acquire() { halInterface->GetSink(sink_stream_cb, get_main_thread(), is_broadcaster_); if (halSinkInterface_ == nullptr) { LOG_ERROR("Can't get Audio HAL Audio sink interface"); log::error("Can't get Audio HAL Audio sink interface"); return false; } Loading @@ -140,7 +141,7 @@ bool SourceImpl::Acquire() { void SourceImpl::Release() { if (le_audio_sink_hal_state_ == HAL_UNINITIALIZED) { LOG_WARN("Audio HAL Audio sink is not running"); log::warn("Audio HAL Audio sink is not running"); return; } Loading @@ -154,7 +155,7 @@ void SourceImpl::Release() { if (halInterface != nullptr) { halInterface->ReleaseSink(halSinkInterface_); } else { LOG_ERROR("Can't get LE Audio HAL interface"); log::error("Can't get LE Audio HAL interface"); } le_audio_sink_hal_state_ = HAL_UNINITIALIZED; Loading @@ -165,7 +166,7 @@ void SourceImpl::Release() { bool SourceImpl::OnResumeReq(bool start_media_task) { std::lock_guard<std::mutex> guard(audioSourceCallbacksMutex_); if (audioSourceCallbacks_ == nullptr) { LOG_ERROR("audioSourceCallbacks_ not set"); log::error("audioSourceCallbacks_ not set"); return false; } bt_status_t status = do_in_main_thread( Loading @@ -176,13 +177,13 @@ bool SourceImpl::OnResumeReq(bool start_media_task) { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } void SourceImpl::SendAudioData() { if (halSinkInterface_ == nullptr) { LOG_ERROR("Audio HAL Audio sink interface not acquired - aborting"); log::error("Audio HAL Audio sink interface not acquired - aborting"); return; } Loading Loading @@ -229,14 +230,14 @@ bool SourceImpl::InitAudioSinkThread() { worker_thread_->StartUp(); if (!worker_thread_->IsRunning()) { LOG_ERROR("Unable to start up the BLE audio sink worker thread"); log::error("Unable to start up the BLE audio sink worker thread"); return false; } /* Schedule the rest of the operations */ if (!worker_thread_->EnableRealTimeScheduling()) { #if defined(__ANDROID__) LOG(FATAL) << __func__ << ", Failed to increase media thread priority"; log::fatal("Failed to increase media thread priority"); #endif } Loading Loading @@ -277,7 +278,7 @@ bool SourceImpl::OnSuspendReq() { } if (audioSourceCallbacks_ == nullptr) { LOG_ERROR("audioSourceCallbacks_ not set"); log::error("audioSourceCallbacks_ not set"); return false; } Loading @@ -289,7 +290,7 @@ bool SourceImpl::OnSuspendReq() { return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -297,7 +298,7 @@ bool SourceImpl::OnMetadataUpdateReq( const source_metadata_v7_t& source_metadata, DsaMode dsa_mode) { std::lock_guard<std::mutex> guard(audioSourceCallbacksMutex_); if (audioSourceCallbacks_ == nullptr) { LOG(ERROR) << __func__ << ", audio receiver not started"; log::error("audio receiver not started"); return false; } Loading @@ -311,7 +312,7 @@ bool SourceImpl::OnMetadataUpdateReq( return true; } LOG_ERROR("do_in_main_thread err=%d", status); log::error("do_in_main_thread err={}", status); return false; } Loading @@ -319,19 +320,19 @@ bool SourceImpl::Start(const LeAudioCodecConfiguration& codec_configuration, LeAudioSourceAudioHalClient::Callbacks* audioReceiver, DsaModes dsa_modes) { if (!halSinkInterface_) { LOG_ERROR("Audio HAL Audio sink interface not acquired"); log::error("Audio HAL Audio sink interface not acquired"); return false; } if (le_audio_sink_hal_state_ == HAL_STARTED) { LOG_ERROR("Audio HAL Audio sink is already in use"); log::error("Audio HAL Audio sink is already in use"); return false; } LOG_INFO("bit rate: %d, num channels: %d, sample rate: %d, data interval: %d", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); log::info( "bit rate: {}, num channels: {}, sample rate: {}, data interval: {}", codec_configuration.bits_per_sample, codec_configuration.num_channels, codec_configuration.sample_rate, codec_configuration.data_interval_us); sStats.Reset(); Loading @@ -355,12 +356,12 @@ bool SourceImpl::Start(const LeAudioCodecConfiguration& codec_configuration, void SourceImpl::Stop() { if (!halSinkInterface_) { LOG_ERROR("Audio HAL Audio sink interface already stopped"); log::error("Audio HAL Audio sink interface already stopped"); return; } if (le_audio_sink_hal_state_ != HAL_STARTED) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -387,7 +388,7 @@ void SourceImpl::Stop() { void SourceImpl::ConfirmStreamingRequest() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -413,7 +414,7 @@ void SourceImpl::ConfirmStreamingRequest() { void SourceImpl::SuspendedForReconfiguration() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -424,7 +425,7 @@ void SourceImpl::SuspendedForReconfiguration() { void SourceImpl::ReconfigurationComplete() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -435,7 +436,7 @@ void SourceImpl::ReconfigurationComplete() { void SourceImpl::CancelStreamingRequest() { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -450,7 +451,7 @@ void SourceImpl::CancelStreamingRequest() { void SourceImpl::UpdateRemoteDelay(uint16_t remote_delay_ms) { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -462,7 +463,7 @@ void SourceImpl::UpdateAudioConfigToHal( const ::bluetooth::le_audio::offload_config& config) { if ((halSinkInterface_ == nullptr) || (le_audio_sink_hal_state_ != HAL_STARTED)) { LOG_ERROR("Audio HAL Audio sink was not started!"); log::error("Audio HAL Audio sink was not started!"); return; } Loading @@ -473,7 +474,7 @@ void SourceImpl::UpdateAudioConfigToHal( void SourceImpl::UpdateBroadcastAudioConfigToHal( const ::bluetooth::le_audio::broadcast_offload_config& config) { if (halSinkInterface_ == nullptr) { LOG_ERROR("Audio HAL Audio sink interface not acquired"); log::error("Audio HAL Audio sink interface not acquired"); return; } Loading @@ -486,7 +487,7 @@ std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::AcquireUnicast() { std::unique_ptr<SourceImpl> impl(new SourceImpl(false)); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Unicast Source on LE Audio HAL enpoint"); log::error("Could not acquire Unicast Source on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading @@ -499,7 +500,7 @@ std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::AcquireBroadcast() { std::unique_ptr<SourceImpl> impl(new SourceImpl(true)); if (!impl->Acquire()) { LOG_ERROR("Could not acquire Broadcast Source on LE Audio HAL enpoint"); log::error("Could not acquire Broadcast Source on LE Audio HAL enpoint"); impl.reset(); return nullptr; } Loading
system/bta/le_audio/broadcaster/broadcaster.cc +81 −81 File changed.Preview size limit exceeded, changes collapsed. Show changes
system/bta/le_audio/broadcaster/broadcaster_test.cc +4 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ * limitations under the License. */ #include <bluetooth/log.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <hardware/audio.h> Loading Loading @@ -53,6 +54,7 @@ using testing::SaveArg; using testing::Test; using namespace bluetooth::le_audio; using namespace bluetooth; using bluetooth::le_audio::DsaMode; using bluetooth::le_audio::LeAudioCodecConfiguration; Loading Loading @@ -90,7 +92,7 @@ bt_status_t do_in_main_thread(const base::Location& from_here, num_async_tasks--; }, std::move(task), std::ref(num_async_tasks)))) { LOG(ERROR) << __func__ << ": failed from " << from_here.ToString(); log::error("failed from {}", from_here.ToString()); return BT_STATUS_FAIL; } num_async_tasks++; Loading @@ -108,7 +110,7 @@ static void init_message_loop_thread() { } if (!message_loop_thread.EnableRealTimeScheduling()) LOG(ERROR) << "Unable to set real time scheduling"; log::error("Unable to set real time scheduling"); message_loop_ = message_loop_thread.message_loop(); if (message_loop_ == nullptr) FAIL() << "unable to get message loop."; Loading