Skip to content

Commit

Permalink
A2DPSink: Fix onConnect and onVolume callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
SomebodyOdd committed Jan 16, 2025
1 parent 196b298 commit c9f9018
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libraries/BluetoothAudio/src/A2DPSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,8 @@ void A2DPSink::avrcp_target_packet_handler(uint8_t packet_type, uint16_t channel
volume_percentage = volume * 100 / 127;
DEBUGV("AVRCP Target : Volume set to %d%% (%d)\n", volume_percentage, volume);
_consumer->setVolume(volume);
if(_volumeCB)
_volumeCB(_volumeData, volume);
break;

case AVRCP_SUBEVENT_OPERATION:
Expand Down Expand Up @@ -773,6 +775,11 @@ void A2DPSink::a2dp_sink_packet_handler(uint8_t packet_type, uint16_t channel, u
DEBUGV("A2DP Sink : Streaming connection is established, address %s, cid 0x%02x, local seid %d\n",
bd_addr_to_str(a2dp_conn->addr), a2dp_conn->a2dp_cid, a2dp_conn->a2dp_local_seid);
memcpy(_sourceAddress, a2dp_conn->addr, sizeof(_sourceAddress));

_connected = true;
if (_connectCB) {
_connectCB(_connectData, true);
}
break;

case A2DP_SUBEVENT_STREAM_STARTED:
Expand All @@ -784,10 +791,6 @@ void A2DPSink::a2dp_sink_packet_handler(uint8_t packet_type, uint16_t channel, u
// prepare media processing
media_processing_init(&a2dp_conn->sbc_configuration);
// audio stream is started when buffer reaches minimal level
_connected = true;
if (_connectCB) {
_connectCB(_connectData, true);
}
break;

case A2DP_SUBEVENT_STREAM_SUSPENDED:
Expand Down

0 comments on commit c9f9018

Please sign in to comment.