// restart the session on the correct thread
message_loop_->DoInThread(
FROM_HERE,
- base::BindOnce(&RenewAudioProviderAndSession,
- base::Unretained(bluetooth_audio_clientif_)));
+ base::BindOnce(
+ &BluetoothAudioClientInterface::RenewAudioProviderAndSession,
+ base::Unretained(bluetooth_audio_clientif_)));
} else {
LOG(ERROR) << __func__ << ": BluetoothAudioClientInterface corrupted";
}
private:
BluetoothAudioClientInterface* bluetooth_audio_clientif_;
bluetooth::common::MessageLoopThread* message_loop_;
- static void RenewAudioProviderAndSession(
- BluetoothAudioClientInterface* bluetooth_audio_clientif) {
- if (bluetooth_audio_clientif != nullptr) {
- bluetooth_audio_clientif->RenewAudioProviderAndSession();
- }
- }
};
BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransportInstance* sink,
int data_interval_ms = -1;
int num_channels = 2;
bluetooth::common::RepeatingTimer audio_timer;
-HearingAidAudioReceiver* localAudioReceiver;
-std::unique_ptr<tUIPC_STATE> uipc_hearing_aid;
+HearingAidAudioReceiver* localAudioReceiver = nullptr;
+std::unique_ptr<tUIPC_STATE> uipc_hearing_aid = nullptr;
struct AudioHalStats {
size_t media_read_total_underflow_bytes;
std::vector<uint8_t> data(p_buf, p_buf + bytes_read);
- localAudioReceiver->OnAudioDataReady(data);
+ if (localAudioReceiver != nullptr) {
+ localAudioReceiver->OnAudioDataReady(data);
+ }
}
void hearing_aid_send_ack(tHEARING_AID_CTRL_ACK status) {
bool hearing_aid_on_resume_req(bool start_media_task) {
// hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_START)
- if (localAudioReceiver) {
+ if (localAudioReceiver != nullptr) {
// Call OnAudioResume and block till it returns.
std::promise<void> do_resume_promise;
std::future<void> do_resume_future = do_resume_promise.get_future();
bool hearing_aid_on_suspend_req() {
// hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_SUSPEND): stop_media_task
stop_audio_ticks();
- if (localAudioReceiver) {
+ if (localAudioReceiver != nullptr) {
// Call OnAudioSuspend and block till it returns.
std::promise<void> do_suspend_promise;
std::future<void> do_suspend_future = do_suspend_promise.get_future();
void HearingAidAudioSource::Start(const CodecConfiguration& codecConfiguration,
HearingAidAudioReceiver* audioReceiver,
uint16_t remote_delay_ms) {
- localAudioReceiver = audioReceiver;
- VLOG(2) << "Hearing Aid UIPC Open";
+ LOG(INFO) << __func__ << ": Hearing Aid Source Open";
bit_rate = codecConfiguration.bit_rate;
sample_rate = codecConfiguration.sample_rate;
bluetooth::audio::hearing_aid::start_session();
bluetooth::audio::hearing_aid::set_remote_delay(remote_delay_ms);
}
+ localAudioReceiver = audioReceiver;
}
void HearingAidAudioSource::Stop() {
+ LOG(INFO) << __func__ << ": Hearing Aid Source Close";
+
+ localAudioReceiver = nullptr;
if (bluetooth::audio::hearing_aid::is_hal_2_0_enabled()) {
bluetooth::audio::hearing_aid::end_session();
}
bluetooth::audio::hearing_aid::cleanup();
} else {
UIPC_Close(*uipc_hearing_aid, UIPC_CH_ID_ALL);
+ uipc_hearing_aid = nullptr;
}
}