blob: 9f1be24ae58939acc32a74ee9d552891dd7fc8dd [file] [log] [blame]
Cheney Niad05f3e2018-11-08 16:41:02 +08001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "BTAudioClientIf"
18
19#include "client_interface.h"
20
21#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioPort.h>
22#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h>
Cheney Ni3abcc012019-03-14 20:58:59 +080023#include <android/hidl/manager/1.2/IServiceManager.h>
Cheney Niad05f3e2018-11-08 16:41:02 +080024#include <base/logging.h>
25#include <hidl/MQDescriptor.h>
Cheney Ni3abcc012019-03-14 20:58:59 +080026#include <hidl/ServiceManagement.h>
Cheney Niad05f3e2018-11-08 16:41:02 +080027#include <future>
28
29#include "osi/include/log.h"
30
31namespace bluetooth {
32namespace audio {
33
34using ::android::hardware::hidl_vec;
35using ::android::hardware::Return;
36using ::android::hardware::Void;
37using ::android::hardware::audio::common::V5_0::SourceMetadata;
38using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
39using ::android::hardware::bluetooth::audio::V2_0::
40 IBluetoothAudioProvidersFactory;
41using DataMQ = ::android::hardware::MessageQueue<
42 uint8_t, ::android::hardware::kSynchronizedReadWrite>;
43
44static constexpr int kDefaultDataReadTimeoutMs = 10; // 10 ms
45static constexpr int kDefaultDataReadPollIntervalMs = 1; // non-blocking poll
Cheney Ni3abcc012019-03-14 20:58:59 +080046static constexpr char kFullyQualifiedInterfaceName[] =
47 "android.hardware.bluetooth.audio@2.0::IBluetoothAudioProvidersFactory";
Cheney Niad05f3e2018-11-08 16:41:02 +080048
49std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack) {
50 switch (ack) {
51 case BluetoothAudioCtrlAck::SUCCESS_FINISHED:
52 return os << "SUCCESS_FINISHED";
53 case BluetoothAudioCtrlAck::PENDING:
54 return os << "PENDING";
55 case BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED:
56 return os << "FAILURE_UNSUPPORTED";
57 case BluetoothAudioCtrlAck::FAILURE_BUSY:
58 return os << "FAILURE_BUSY";
59 case BluetoothAudioCtrlAck::FAILURE_DISCONNECTING:
60 return os << "FAILURE_DISCONNECTING";
61 case BluetoothAudioCtrlAck::FAILURE:
62 return os << "FAILURE";
63 default:
64 return os << "UNDEFINED " << static_cast<int8_t>(ack);
65 }
66}
67
68// Internal class within BluetoothAudioClientInterfaceace to implement
69// IBluetoothAudioPort (control interface used by Bluetooth Audio HAL)
70class BluetoothAudioPortImpl : public IBluetoothAudioPort {
71 public:
72 BluetoothAudioPortImpl(IBluetoothTransportInstance* sink,
73 const android::sp<IBluetoothAudioProvider>& provider)
74 : sink_(sink), provider_(provider){};
75
Yi Kong183eace2019-03-29 15:42:58 -070076 Return<void> startStream() override {
Cheney Niad05f3e2018-11-08 16:41:02 +080077 BluetoothAudioCtrlAck ack = sink_->StartRequest();
78 if (ack != BluetoothAudioCtrlAck::PENDING) {
79 auto hidl_retval =
80 provider_->streamStarted(BluetoothAudioCtrlAckToHalStatus(ack));
81 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +080082 LOG(ERROR) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +080083 }
84 }
85 return Void();
86 }
87
Yi Kong183eace2019-03-29 15:42:58 -070088 Return<void> suspendStream() override {
Cheney Niad05f3e2018-11-08 16:41:02 +080089 BluetoothAudioCtrlAck ack = sink_->SuspendRequest();
90 if (ack != BluetoothAudioCtrlAck::PENDING) {
91 auto hidl_retval =
92 provider_->streamSuspended(BluetoothAudioCtrlAckToHalStatus(ack));
93 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +080094 LOG(ERROR) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +080095 }
96 }
97 return Void();
98 }
99
Yi Kong183eace2019-03-29 15:42:58 -0700100 Return<void> stopStream() override {
Cheney Niad05f3e2018-11-08 16:41:02 +0800101 sink_->StopRequest();
102 return Void();
103 }
104
Yi Kong183eace2019-03-29 15:42:58 -0700105 Return<void> getPresentationPosition(
106 getPresentationPosition_cb _hidl_cb) override {
Cheney Niad05f3e2018-11-08 16:41:02 +0800107 uint64_t remote_delay_report_ns;
108 uint64_t total_bytes_read;
109 timespec data_position;
110 bool retval = sink_->GetPresentationPosition(
111 &remote_delay_report_ns, &total_bytes_read, &data_position);
112
113 TimeSpec transmittedOctetsTimeStamp;
114 if (retval) {
115 transmittedOctetsTimeStamp = timespec_convert_to_hal(data_position);
116 } else {
117 remote_delay_report_ns = 0;
118 total_bytes_read = 0;
119 transmittedOctetsTimeStamp = {};
120 }
121 VLOG(2) << __func__ << ": result=" << retval
122 << ", delay=" << remote_delay_report_ns
123 << ", data=" << total_bytes_read
124 << " byte(s), timestamp=" << toString(transmittedOctetsTimeStamp);
125 _hidl_cb((retval ? BluetoothAudioStatus::SUCCESS
126 : BluetoothAudioStatus::FAILURE),
127 remote_delay_report_ns, total_bytes_read,
128 transmittedOctetsTimeStamp);
129 return Void();
130 }
131
Yi Kong183eace2019-03-29 15:42:58 -0700132 Return<void> updateMetadata(const SourceMetadata& sourceMetadata) override {
Cheney Niad05f3e2018-11-08 16:41:02 +0800133 LOG(INFO) << __func__ << ": " << sourceMetadata.tracks.size()
134 << " track(s)";
135 // refer to StreamOut.impl.h within Audio HAL (AUDIO_HAL_VERSION_5_0)
136 std::vector<playback_track_metadata> metadata_vec;
137 metadata_vec.reserve(sourceMetadata.tracks.size());
138 for (const auto& metadata : sourceMetadata.tracks) {
139 metadata_vec.push_back({
140 .usage = static_cast<audio_usage_t>(metadata.usage),
141 .content_type =
142 static_cast<audio_content_type_t>(metadata.contentType),
143 .gain = metadata.gain,
144 });
145 }
146 const source_metadata_t source_metadata = {
147 .track_count = metadata_vec.size(), .tracks = metadata_vec.data()};
148 sink_->MetadataChanged(source_metadata);
149 return Void();
150 }
151
152 private:
153 IBluetoothTransportInstance* sink_;
154 const android::sp<IBluetoothAudioProvider> provider_;
155 TimeSpec timespec_convert_to_hal(const timespec& ts) {
156 return {.tvSec = static_cast<uint64_t>(ts.tv_sec),
157 .tvNSec = static_cast<uint64_t>(ts.tv_nsec)};
158 }
159};
160
161class BluetoothAudioDeathRecipient
162 : public ::android::hardware::hidl_death_recipient {
163 public:
164 BluetoothAudioDeathRecipient(
165 BluetoothAudioClientInterface* clientif,
166 bluetooth::common::MessageLoopThread* message_loop)
167 : bluetooth_audio_clientif_(clientif), message_loop_(message_loop) {}
168 void serviceDied(
169 uint64_t /*cookie*/,
Yi Kong183eace2019-03-29 15:42:58 -0700170 const ::android::wp<::android::hidl::base::V1_0::IBase>& /*who*/)
171 override {
Cheney Niad05f3e2018-11-08 16:41:02 +0800172 LOG(WARNING) << __func__ << ": restarting connection with new Audio Hal";
173 if (bluetooth_audio_clientif_ != nullptr && message_loop_ != nullptr) {
174 // restart the session on the correct thread
175 message_loop_->DoInThread(
176 FROM_HERE,
Cheney Ni39be2412019-05-24 14:59:43 +0800177 base::BindOnce(
178 &BluetoothAudioClientInterface::RenewAudioProviderAndSession,
179 base::Unretained(bluetooth_audio_clientif_)));
Cheney Niad05f3e2018-11-08 16:41:02 +0800180 } else {
181 LOG(ERROR) << __func__ << ": BluetoothAudioClientInterface corrupted";
182 }
183 }
184
185 private:
186 BluetoothAudioClientInterface* bluetooth_audio_clientif_;
187 bluetooth::common::MessageLoopThread* message_loop_;
Cheney Niad05f3e2018-11-08 16:41:02 +0800188};
189
Cheney Ni3abcc012019-03-14 20:58:59 +0800190BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransportInstance* sink,
191 bluetooth::common::MessageLoopThread* message_loop)
192 : sink_(sink), provider_(nullptr), session_started_(false), mDataMQ(nullptr),
Cheney Niad05f3e2018-11-08 16:41:02 +0800193 death_recipient_(new BluetoothAudioDeathRecipient(this, message_loop)) {
Cheney Ni3abcc012019-03-14 20:58:59 +0800194 auto service_manager = android::hardware::defaultServiceManager1_2();
195 CHECK(service_manager != nullptr);
196 size_t instance_count = 0;
197 auto listManifestByInterface_cb = [&instance_count](const hidl_vec<android::hardware::hidl_string>& instanceNames) {
198 instance_count = instanceNames.size();
199 LOG(INFO) << "listManifestByInterface_cb returns " << instance_count << " instance(s)";
200 };
201 auto hidl_retval = service_manager->listManifestByInterface(kFullyQualifiedInterfaceName, listManifestByInterface_cb);
202 if (!hidl_retval.isOk()) {
203 LOG(FATAL) << __func__ << ": IServiceManager::listByInterface failure: " << hidl_retval.description();
204 }
205 if (instance_count > 0) {
206 fetch_audio_provider();
207 } else {
208 LOG(WARNING) << "IBluetoothAudioProvidersFactory not declared";
209 }
Cheney Niad05f3e2018-11-08 16:41:02 +0800210}
211
212BluetoothAudioClientInterface::~BluetoothAudioClientInterface() {
213 if (provider_ != nullptr) {
214 auto hidl_retval = provider_->unlinkToDeath(death_recipient_);
215 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800216 LOG(FATAL) << __func__ << ": BluetoothAudioDeathRecipient failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800217 }
218 }
219}
220
221std::vector<AudioCapabilities>
222BluetoothAudioClientInterface::GetAudioCapabilities() const {
223 return capabilities_;
224}
225
226void BluetoothAudioClientInterface::fetch_audio_provider() {
227 if (provider_ != nullptr) {
228 LOG(WARNING) << __func__ << ": reflash";
229 }
230
231 android::sp<IBluetoothAudioProvidersFactory> providersFactory =
232 IBluetoothAudioProvidersFactory::getService();
Cheney Ni3abcc012019-03-14 20:58:59 +0800233 CHECK(providersFactory != nullptr) << "IBluetoothAudioProvidersFactory::getService() failed";
Cheney Niad05f3e2018-11-08 16:41:02 +0800234 LOG(INFO) << "IBluetoothAudioProvidersFactory::getService() returned "
235 << providersFactory.get()
236 << (providersFactory->isRemote() ? " (remote)" : " (local)");
Cheney Niad05f3e2018-11-08 16:41:02 +0800237
238 std::promise<void> getProviderCapabilities_promise;
239 auto getProviderCapabilities_future =
240 getProviderCapabilities_promise.get_future();
241 auto getProviderCapabilities_cb =
242 [& capabilities = this->capabilities_, &getProviderCapabilities_promise](
243 const hidl_vec<AudioCapabilities>& audioCapabilities) {
244 for (auto capability : audioCapabilities) {
245 capabilities.push_back(capability);
246 }
247 getProviderCapabilities_promise.set_value();
248 };
249 auto hidl_retval = providersFactory->getProviderCapabilities(
250 sink_->GetSessionType(), getProviderCapabilities_cb);
251 getProviderCapabilities_future.get();
252 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800253 LOG(FATAL) << __func__ << ": BluetoothAudioHal::getProviderCapabilities failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800254 return;
Cheney Nifff829f2019-03-07 14:15:27 +0800255 }
256 if (capabilities_.empty()) {
Cheney Niad05f3e2018-11-08 16:41:02 +0800257 LOG(WARNING) << __func__
258 << ": SessionType=" << toString(sink_->GetSessionType())
259 << " Not supported by BluetoothAudioHal";
260 return;
261 }
262 LOG(INFO) << __func__ << ": BluetoothAudioHal SessionType="
263 << toString(sink_->GetSessionType()) << " has "
264 << capabilities_.size() << " AudioCapabilities";
265
266 std::promise<void> openProvider_promise;
267 auto openProvider_future = openProvider_promise.get_future();
268 auto openProvider_cb =
269 [& provider_ = this->provider_, &openProvider_promise](
270 BluetoothAudioStatus status,
271 const android::sp<IBluetoothAudioProvider>& provider) {
272 LOG(INFO) << "openProvider_cb(" << toString(status) << ")";
273 if (status == BluetoothAudioStatus::SUCCESS) {
274 provider_ = provider;
275 }
276 ALOGE_IF(!provider_, "Failed to open BluetoothAudio provider");
277 openProvider_promise.set_value();
278 };
279 hidl_retval =
280 providersFactory->openProvider(sink_->GetSessionType(), openProvider_cb);
281 openProvider_future.get();
282 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800283 LOG(FATAL) << __func__ << ": BluetoothAudioHal::openProvider failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800284 }
285 CHECK(provider_ != nullptr);
286
287 if (!provider_->linkToDeath(death_recipient_, 0).isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800288 LOG(FATAL) << __func__ << ": BluetoothAudioDeathRecipient failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800289 }
290
291 LOG(INFO) << "IBluetoothAudioProvidersFactory::openProvider() returned "
292 << provider_.get()
293 << (provider_->isRemote() ? " (remote)" : " (local)");
294}
295
296bool BluetoothAudioClientInterface::UpdateAudioConfig(
297 const AudioConfiguration& audio_config) {
298 bool is_software_session =
299 (sink_->GetSessionType() ==
300 SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH ||
301 sink_->GetSessionType() ==
302 SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH);
303 bool is_offload_session =
304 (sink_->GetSessionType() == SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH);
305 auto audio_config_discriminator = audio_config.getDiscriminator();
306 bool is_software_audio_config =
307 (is_software_session &&
308 audio_config_discriminator ==
309 AudioConfiguration::hidl_discriminator::pcmConfig);
310 bool is_offload_audio_config =
311 (is_offload_session &&
312 audio_config_discriminator ==
313 AudioConfiguration::hidl_discriminator::codecConfig);
314 if (!is_software_audio_config && !is_offload_audio_config) {
315 return false;
316 }
317 sink_->UpdateAudioConfiguration(audio_config);
318 return true;
319}
320
321int BluetoothAudioClientInterface::StartSession() {
322 std::lock_guard<std::mutex> guard(internal_mutex_);
323 if (provider_ == nullptr) {
324 LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr";
325 session_started_ = false;
326 return -EINVAL;
327 }
328 if (session_started_) {
329 LOG(ERROR) << __func__ << ": session started already";
330 return -EBUSY;
331 }
332
333 android::sp<IBluetoothAudioPort> stack_if =
334 new BluetoothAudioPortImpl(sink_, provider_);
335 std::unique_ptr<DataMQ> tempDataMQ;
336 BluetoothAudioStatus session_status;
337
338 std::promise<void> hidl_startSession_promise;
339 auto hidl_startSession_future = hidl_startSession_promise.get_future();
340 auto hidl_cb = [&session_status, &tempDataMQ, &hidl_startSession_promise](
341 BluetoothAudioStatus status,
342 const DataMQ::Descriptor& dataMQ) {
343 LOG(INFO) << "startSession_cb(" << toString(status) << ")";
344 session_status = status;
345 if (status == BluetoothAudioStatus::SUCCESS && dataMQ.isHandleValid()) {
346 tempDataMQ.reset(new DataMQ(dataMQ));
347 }
348 hidl_startSession_promise.set_value();
349 };
350 auto hidl_retval = provider_->startSession(
351 stack_if, sink_->GetAudioConfiguration(), hidl_cb);
352 hidl_startSession_future.get();
353 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800354 LOG(FATAL) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800355 return -EPROTO;
356 }
357
358 if (tempDataMQ && tempDataMQ->isValid()) {
359 mDataMQ = std::move(tempDataMQ);
360 } else if (sink_->GetSessionType() ==
361 SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH &&
362 session_status == BluetoothAudioStatus::SUCCESS) {
363 sink_->ResetPresentationPosition();
364 session_started_ = true;
365 return 0;
366 }
367 if (mDataMQ && mDataMQ->isValid()) {
368 sink_->ResetPresentationPosition();
369 session_started_ = true;
370 return 0;
371 } else {
372 ALOGE_IF(!mDataMQ, "Failed to obtain audio data path");
373 ALOGE_IF(mDataMQ && !mDataMQ->isValid(), "Audio data path is invalid");
374 session_started_ = false;
375 return -EIO;
376 }
377}
378
379void BluetoothAudioClientInterface::StreamStarted(
380 const BluetoothAudioCtrlAck& ack) {
381 if (provider_ == nullptr) {
382 LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr";
383 return;
Cheney Nifff829f2019-03-07 14:15:27 +0800384 }
385 if (ack == BluetoothAudioCtrlAck::PENDING) {
Cheney Niad05f3e2018-11-08 16:41:02 +0800386 LOG(INFO) << __func__ << ": " << ack << " ignored";
387 return;
388 }
389 BluetoothAudioStatus status = BluetoothAudioCtrlAckToHalStatus(ack);
390 auto hidl_retval = provider_->streamStarted(status);
391 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800392 LOG(ERROR) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800393 }
394}
395
396void BluetoothAudioClientInterface::StreamSuspended(
397 const BluetoothAudioCtrlAck& ack) {
398 if (provider_ == nullptr) {
399 LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr";
400 return;
Cheney Nifff829f2019-03-07 14:15:27 +0800401 }
402 if (ack == BluetoothAudioCtrlAck::PENDING) {
Cheney Niad05f3e2018-11-08 16:41:02 +0800403 LOG(INFO) << __func__ << ": " << ack << " ignored";
404 return;
405 }
406 BluetoothAudioStatus status = BluetoothAudioCtrlAckToHalStatus(ack);
407 auto hidl_retval = provider_->streamSuspended(status);
408 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800409 LOG(ERROR) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800410 }
411}
412
413int BluetoothAudioClientInterface::EndSession() {
414 std::lock_guard<std::mutex> guard(internal_mutex_);
415 if (!session_started_) {
416 LOG(INFO) << __func__ << ": sessoin ended already";
417 return 0;
418 }
419
420 session_started_ = false;
421 if (provider_ == nullptr) {
422 LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr";
423 return -EINVAL;
424 }
425 mDataMQ = nullptr;
426 auto hidl_retval = provider_->endSession();
427 if (!hidl_retval.isOk()) {
Cheney Nifff829f2019-03-07 14:15:27 +0800428 LOG(ERROR) << __func__ << ": BluetoothAudioHal failure: " << hidl_retval.description();
Cheney Niad05f3e2018-11-08 16:41:02 +0800429 return -EPROTO;
430 }
431 return 0;
432}
433
434size_t BluetoothAudioClientInterface::ReadAudioData(uint8_t* p_buf,
435 uint32_t len) {
436 if (provider_ == nullptr) {
437 LOG(ERROR) << __func__ << ": BluetoothAudioHal nullptr";
438 return 0;
439 }
440 if (p_buf == nullptr || len == 0) return 0;
441
442 std::lock_guard<std::mutex> guard(internal_mutex_);
443
444 size_t total_read = 0;
445 int timeout_ms = kDefaultDataReadTimeoutMs;
446 do {
447 if (mDataMQ == nullptr || !mDataMQ->isValid()) break;
448
449 size_t avail_to_read = mDataMQ->availableToRead();
450 if (avail_to_read) {
451 if (avail_to_read > len - total_read) {
452 avail_to_read = len - total_read;
453 }
454 if (mDataMQ->read(p_buf + total_read, avail_to_read) == 0) {
455 LOG(WARNING) << __func__ << ": len=" << len
456 << " total_read=" << total_read << " failed";
457 break;
458 }
459 total_read += avail_to_read;
460 } else if (timeout_ms >= kDefaultDataReadPollIntervalMs) {
461 std::this_thread::sleep_for(
462 std::chrono::milliseconds(kDefaultDataReadPollIntervalMs));
463 timeout_ms -= kDefaultDataReadPollIntervalMs;
464 continue;
465 } else {
466 LOG(WARNING) << __func__ << ": " << (len - total_read) << "/" << len
467 << " no data " << (kDefaultDataReadTimeoutMs - timeout_ms)
468 << " ms";
469 break;
470 }
471 } while (total_read < len);
472
473 if (timeout_ms <
474 (kDefaultDataReadTimeoutMs - kDefaultDataReadPollIntervalMs) &&
475 timeout_ms >= kDefaultDataReadPollIntervalMs) {
476 VLOG(1) << __func__ << ": underflow " << len << " -> " << total_read
477 << " read " << (kDefaultDataReadTimeoutMs - timeout_ms) << " ms";
478 } else {
479 VLOG(2) << __func__ << ": " << len << " -> " << total_read << " read";
480 }
481
482 sink_->LogBytesRead(total_read);
483 return total_read;
484}
485
486size_t BluetoothAudioClientInterface::WriteAudioData(uint8_t* p_buf,
487 uint32_t len) {
488 // Not implemented!
489 return 0;
490}
491
492void BluetoothAudioClientInterface::RenewAudioProviderAndSession() {
493 // NOTE: must be invoked on the same thread where this
494 // BluetoothAudioClientInterface is running
495 fetch_audio_provider();
496 session_started_ = false;
497 StartSession();
498}
499
500} // namespace audio
501} // namespace bluetooth