• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


コミットメタ情報

リビジョン14826309312a3b35ca70d38dd9ab3972f6a6bf85 (tree)
日時2019-05-31 15:03:04
作者Cheney Ni <cheneyni@goog...>
コミッターandroid-build-merger

ログメッセージ

Make sure the Hearing Aid source is ready before resuming or suspending calls
am: 2e4fd6f728

Change-Id: I3d483a0d35b19defe7be94b53f9c6dd5cf1f7b20

変更サマリ

差分

--- a/audio_hal_interface/client_interface.cc
+++ b/audio_hal_interface/client_interface.cc
@@ -172,8 +172,9 @@ class BluetoothAudioDeathRecipient
172172 // restart the session on the correct thread
173173 message_loop_->DoInThread(
174174 FROM_HERE,
175- base::BindOnce(&RenewAudioProviderAndSession,
176- base::Unretained(bluetooth_audio_clientif_)));
175+ base::BindOnce(
176+ &BluetoothAudioClientInterface::RenewAudioProviderAndSession,
177+ base::Unretained(bluetooth_audio_clientif_)));
177178 } else {
178179 LOG(ERROR) << __func__ << ": BluetoothAudioClientInterface corrupted";
179180 }
@@ -182,12 +183,6 @@ class BluetoothAudioDeathRecipient
182183 private:
183184 BluetoothAudioClientInterface* bluetooth_audio_clientif_;
184185 bluetooth::common::MessageLoopThread* message_loop_;
185- static void RenewAudioProviderAndSession(
186- BluetoothAudioClientInterface* bluetooth_audio_clientif) {
187- if (bluetooth_audio_clientif != nullptr) {
188- bluetooth_audio_clientif->RenewAudioProviderAndSession();
189- }
190- }
191186 };
192187
193188 BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransportInstance* sink,
--- a/audio_hal_interface/hearing_aid_software_encoding.cc
+++ b/audio_hal_interface/hearing_aid_software_encoding.cc
@@ -68,11 +68,11 @@ class HearingAidTransport
6868
6969 void StopRequest() override {
7070 LOG(INFO) << __func__;
71- stream_cb_.on_suspend_();
72-
73- // flush
74- uint8_t p_buf[AUDIO_STREAM_OUTPUT_BUFFER_SZ * 2];
75- ::bluetooth::audio::hearing_aid::read(p_buf, sizeof(p_buf));
71+ if (stream_cb_.on_suspend_()) {
72+ // flush
73+ uint8_t p_buf[AUDIO_STREAM_OUTPUT_BUFFER_SZ * 2];
74+ ::bluetooth::audio::hearing_aid::read(p_buf, sizeof(p_buf));
75+ }
7676 }
7777
7878 bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
--- a/bta/hearing_aid/hearing_aid_audio_source.cc
+++ b/bta/hearing_aid/hearing_aid_audio_source.cc
@@ -38,8 +38,8 @@ int sample_rate = -1;
3838 int data_interval_ms = -1;
3939 int num_channels = 2;
4040 bluetooth::common::RepeatingTimer audio_timer;
41-HearingAidAudioReceiver* localAudioReceiver;
42-std::unique_ptr<tUIPC_STATE> uipc_hearing_aid;
41+HearingAidAudioReceiver* localAudioReceiver = nullptr;
42+std::unique_ptr<tUIPC_STATE> uipc_hearing_aid = nullptr;
4343
4444 struct AudioHalStats {
4545 size_t media_read_total_underflow_bytes;
@@ -85,7 +85,9 @@ void send_audio_data() {
8585
8686 std::vector<uint8_t> data(p_buf, p_buf + bytes_read);
8787
88- localAudioReceiver->OnAudioDataReady(data);
88+ if (localAudioReceiver != nullptr) {
89+ localAudioReceiver->OnAudioDataReady(data);
90+ }
8991 }
9092
9193 void hearing_aid_send_ack(tHEARING_AID_CTRL_ACK status) {
@@ -305,7 +307,7 @@ void hearing_aid_ctrl_cb(tUIPC_CH_ID, tUIPC_EVENT event) {
305307
306308 bool hearing_aid_on_resume_req(bool start_media_task) {
307309 // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_START)
308- if (localAudioReceiver) {
310+ if (localAudioReceiver != nullptr) {
309311 // Call OnAudioResume and block till it returns.
310312 std::promise<void> do_resume_promise;
311313 std::future<void> do_resume_future = do_resume_promise.get_future();
@@ -342,7 +344,7 @@ bool hearing_aid_on_resume_req(bool start_media_task) {
342344 bool hearing_aid_on_suspend_req() {
343345 // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_SUSPEND): stop_media_task
344346 stop_audio_ticks();
345- if (localAudioReceiver) {
347+ if (localAudioReceiver != nullptr) {
346348 // Call OnAudioSuspend and block till it returns.
347349 std::promise<void> do_suspend_promise;
348350 std::future<void> do_suspend_future = do_suspend_promise.get_future();
@@ -369,8 +371,7 @@ bool hearing_aid_on_suspend_req() {
369371 void HearingAidAudioSource::Start(const CodecConfiguration& codecConfiguration,
370372 HearingAidAudioReceiver* audioReceiver,
371373 uint16_t remote_delay_ms) {
372- localAudioReceiver = audioReceiver;
373- VLOG(2) << "Hearing Aid UIPC Open";
374+ LOG(INFO) << __func__ << ": Hearing Aid Source Open";
374375
375376 bit_rate = codecConfiguration.bit_rate;
376377 sample_rate = codecConfiguration.sample_rate;
@@ -382,9 +383,13 @@ void HearingAidAudioSource::Start(const CodecConfiguration& codecConfiguration,
382383 bluetooth::audio::hearing_aid::start_session();
383384 bluetooth::audio::hearing_aid::set_remote_delay(remote_delay_ms);
384385 }
386+ localAudioReceiver = audioReceiver;
385387 }
386388
387389 void HearingAidAudioSource::Stop() {
390+ LOG(INFO) << __func__ << ": Hearing Aid Source Close";
391+
392+ localAudioReceiver = nullptr;
388393 if (bluetooth::audio::hearing_aid::is_hal_2_0_enabled()) {
389394 bluetooth::audio::hearing_aid::end_session();
390395 }
@@ -409,6 +414,7 @@ void HearingAidAudioSource::CleanUp() {
409414 bluetooth::audio::hearing_aid::cleanup();
410415 } else {
411416 UIPC_Close(*uipc_hearing_aid, UIPC_CH_ID_ALL);
417+ uipc_hearing_aid = nullptr;
412418 }
413419 }
414420