Skip to content

Commit

Permalink
BT-HAP: HearingAid misc fixes.
Browse files Browse the repository at this point in the history
  - ensure encoded data is captured.
  - change alarm to periodic.
  - suspend request always returned false
    causing issue w.r.t. resume audio.

Change-Id: I395fcd1fd651d3bbbbbcca40e35056f46cd2ecec
  • Loading branch information
Kiran Kelageri committed Feb 19, 2020
1 parent 1e01424 commit cdfd3ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bta/hearing_aid/hearing_aid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ class HearingAidImpl : public HearingAid {
encoded_data_left.resize(4000);
int encoded_size = 0;
if (chan_left.size() > 0) {
g722_encode(encoder_state_left, encoded_data_left.data(),
encoded_size = g722_encode(encoder_state_left, encoded_data_left.data(),
(const int16_t*)chan_left.data(), chan_left.size());
} else {
LOG(ERROR) << "Error: No chan_left data to encode";
Expand Down Expand Up @@ -1242,7 +1242,7 @@ class HearingAidImpl : public HearingAid {
encoded_data_right.resize(4000);
int encoded_size = 0;
if (chan_right.size() > 0) {
g722_encode(encoder_state_right, encoded_data_right.data(),
encoded_size = g722_encode(encoder_state_right, encoded_data_right.data(),
(const int16_t*)chan_right.data(), chan_right.size());
} else {
LOG(ERROR) << "Error: No chan_right data to encode";
Expand Down
7 changes: 4 additions & 3 deletions bta/hearing_aid/hearing_aid_audio_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ bool hearing_aid_on_suspend_req() {
FROM_HERE, base::Bind(&HearingAidAudioReceiver::OnAudioSuspend,
base::Unretained(localAudioReceiver),
base::Passed(std::move(do_suspend_promise))));
return true;
} else {
LOG(ERROR) << __func__
<< ": HEARING_AID_CTRL_CMD_SUSPEND: audio receiver not started";
Expand Down Expand Up @@ -378,9 +379,9 @@ void HearingAidAudioSource::Initialize() {
.on_suspend_ = hearing_aid_on_suspend_req,
};

audio_timer = alarm_new("hearing_aid_data_timer");
if (!audio_timer) {
LOG(WARNING) << __func__ << ": unable to create alarm.";
audio_timer = alarm_new_periodic("hearing_aid_data_timer");
if (audio_timer == nullptr) {
LOG(ERROR) << "unable to allocate hearing_aid_data_timer" << __func__;
return;
}
if ((get_worker_thread() == NULL) || !bluetooth::audio::hearing_aid::init(stream_cb, get_worker_thread())) {
Expand Down

0 comments on commit cdfd3ac

Please sign in to comment.