Skip to content

Commit

Permalink
Revert "Test adding delay before stopping audio stream"
Browse files Browse the repository at this point in the history
This reverts commit 726ebd9.
  • Loading branch information
shermp committed Feb 21, 2025
1 parent 531eff6 commit 0bf7062
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/hearing_aid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ void HearingAid::handle_gatt_notification(PACKET_HANDLER_PARAMS)
if (ha->other && ha->other->is_streaming()) {
ha->other->send_acp_status(ACPStatus::other_connected);
}
} else if (ha->audio_state == (AudioState::Stop | AudioState::AudioBusy)) {
} else if (ha->audio_state == AudioState::Stop) {
LOG_INFO("%s: Audio stop OK", ha->get_side_str());
ha->audio_state = AudioState::Ready;
}
Expand All @@ -792,16 +792,8 @@ void __not_in_flash_func(HearingAid::process_audio)()
bool pcm_is_streaming = audio_buff.pcm_streaming.Load();
for (auto ha : hearing_aids) {
if (ha->process_state != ProcessState::Audio) { continue; }
if (ha->audio_process_delay_ticks > 0) {
--(ha->audio_process_delay_ticks);
continue;
}
ha->credits = l2cap_cbm_available_credits(ha->cid);
switch (ha->audio_state) {
case AudioState::Stop:
ha->set_audio_busy();
ha->send_acp_stop();
break;
case AudioState::Ready:
if (pcm_is_streaming && ha->credits >= 8) {
ha->set_audio_busy();
Expand All @@ -815,8 +807,7 @@ void __not_in_flash_func(HearingAid::process_audio)()
}
LOG_INFO("%s: Stopping audio stream. PCM Streaming: %d, Credits: %d",
ha->get_side_str(), (int)pcm_is_streaming, (int)ha->credits);
ha->audio_process_delay_ticks += 100;
ha->audio_state = AudioState::Stop;
ha->send_acp_stop();
} else {
// Send volume update if volume has changed
int8_t v = ha->rop.side == Side::Left ? vol.l : vol.r;
Expand Down Expand Up @@ -973,6 +964,7 @@ void HearingAid::send_acp_start()

void HearingAid::send_acp_stop()
{
audio_state = AudioState::Stop;
acp_cmd_packet[0] = ACPOpCode::stop;
uint8_t res = gatt_client_write_value_of_characteristic(&HearingAid::handle_acp_write,
conn_handle,
Expand Down
1 change: 0 additions & 1 deletion src/hearing_aid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ struct HearingAid
inline static std::array<HearingAid*, 2> hearing_aids;

int process_delay_ticks = 0;
int audio_process_delay_ticks = 0;
uint32_t curr_write_index = 0U;
uint32_t curr_read_index = 0U;
uint8_t* audio_data = nullptr;
Expand Down

0 comments on commit 0bf7062

Please sign in to comment.