From 3d3b997cc034dd96eef98370927b464ea9a7d5ad Mon Sep 17 00:00:00 2001 From: SP2FET Date: Tue, 23 Feb 2021 14:00:15 +0100 Subject: [PATCH] [EGD-5856] Update Btstack Updated to the latest version, fixes few bugs --- .../interface/profiles/A2DP/A2DP.cpp | 49 +++++++++---------- .../interface/profiles/A2DP/AVDTP.hpp | 6 +-- .../Bluetooth/interface/profiles/GAP/GAP.cpp | 2 +- module-bluetooth/lib/btstack | 2 +- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp index d3fb1c63dd64e7b76d99f98bdd8f97a3d5a20141..d372a918e20583db8c2073473fdbe06acbb1ef70 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp +++ b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp @@ -338,7 +338,7 @@ namespace bluetooth return; } AVRCP::mediaTracker.remote_seid = - a2dp_subevent_signaling_media_codec_sbc_configuration_get_acp_seid(packet); + a2dp_subevent_signaling_media_codec_sbc_configuration_get_remote_seid(packet); AVDTP::sbcConfig.reconfigure = a2dp_subevent_signaling_media_codec_sbc_configuration_get_reconfigure(packet); @@ -346,43 +346,40 @@ namespace bluetooth a2dp_subevent_signaling_media_codec_sbc_configuration_get_num_channels(packet); AVDTP::sbcConfig.samplingFrequency = a2dp_subevent_signaling_media_codec_sbc_configuration_get_sampling_frequency(packet); - AVDTP::sbcConfig.channelMode = - a2dp_subevent_signaling_media_codec_sbc_configuration_get_channel_mode(packet); AVDTP::sbcConfig.blockLength = a2dp_subevent_signaling_media_codec_sbc_configuration_get_block_length(packet); AVDTP::sbcConfig.subbands = a2dp_subevent_signaling_media_codec_sbc_configuration_get_subbands(packet); - AVDTP::sbcConfig.allocationMethod = - a2dp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet); AVDTP::sbcConfig.minBitpoolValue = a2dp_subevent_signaling_media_codec_sbc_configuration_get_min_bitpool_value(packet); AVDTP::sbcConfig.maxBitpoolValue = a2dp_subevent_signaling_media_codec_sbc_configuration_get_max_bitpool_value(packet); - AVDTP::sbcConfig.framesPerBuffer = AVDTP::sbcConfig.subbands * AVDTP::sbcConfig.blockLength; - LOG_INFO( - "A2DP Source: Received SBC codec configuration, sampling frequency %u, a2dp_cid 0x%02x, local seid %d " - "(expected %d), remote seid %d .\n", - AVDTP::sbcConfig.samplingFrequency, - cid, - a2dp_subevent_signaling_media_codec_sbc_configuration_get_int_seid(packet), - AVRCP::mediaTracker.local_seid, - AVRCP::mediaTracker.remote_seid); + LOG_INFO("A2DP Source: Received SBC codec configuration, sampling frequency %u, a2dp_cid 0x%02x, local " + "seid 0x%02x, remote seid 0x%02x.\n", + AVDTP::sbcConfig.samplingFrequency, + cid, + AVRCP::mediaTracker.local_seid, + AVRCP::mediaTracker.remote_seid); // Adapt Bluetooth spec definition to SBC Encoder expected input - AVDTP::sbcConfig.allocationMethod -= 1; + auto allocation_method = + a2dp_subevent_signaling_media_codec_sbc_configuration_get_allocation_method(packet); + AVDTP::sbcConfig.allocationMethod = static_cast(allocation_method - 1); + auto channel_mode = static_cast( + a2dp_subevent_signaling_media_codec_sbc_configuration_get_channel_mode(packet)); + AVDTP::sbcConfig.numChannels = 2; - switch (AVDTP::sbcConfig.channelMode) { - case AVDTP_SBC_JOINT_STEREO: - AVDTP::sbcConfig.channelMode = 3; + switch (channel_mode) { + case AVDTP_CHANNEL_MODE_JOINT_STEREO: + AVDTP::sbcConfig.channelMode = SBC_CHANNEL_MODE_JOINT_STEREO; break; - case AVDTP_SBC_STEREO: - AVDTP::sbcConfig.channelMode = 2; + case AVDTP_CHANNEL_MODE_STEREO: + AVDTP::sbcConfig.channelMode = SBC_CHANNEL_MODE_STEREO; break; - case AVDTP_SBC_DUAL_CHANNEL: - AVDTP::sbcConfig.channelMode = 1; + case AVDTP_CHANNEL_MODE_DUAL_CHANNEL: + AVDTP::sbcConfig.channelMode = SBC_CHANNEL_MODE_DUAL_CHANNEL; break; - case AVDTP_SBC_MONO: - AVDTP::sbcConfig.channelMode = 0; - AVDTP::sbcConfig.numChannels = 1; + case AVDTP_CHANNEL_MODE_MONO: + AVDTP::sbcConfig.channelMode = SBC_CHANNEL_MODE_MONO; break; } AVDTP::dumpSbcConfiguration(); @@ -565,7 +562,7 @@ namespace bluetooth void A2DP::A2DPImpl::start() { LOG_INFO("Starting playback to %s", bd_addr_to_str(deviceAddr)); - a2dp_source_establish_stream(deviceAddr, AVRCP::mediaTracker.local_seid, &AVRCP::mediaTracker.a2dp_cid); + a2dp_source_establish_stream(deviceAddr, &AVRCP::mediaTracker.a2dp_cid); } void A2DP::A2DPImpl::stop() diff --git a/module-bluetooth/Bluetooth/interface/profiles/A2DP/AVDTP.hpp b/module-bluetooth/Bluetooth/interface/profiles/A2DP/AVDTP.hpp index 06df71ca62eb35597bf8db86a295961b62e0edf1..fab3ae4267a6926953c0b34d2ace751b3955332e 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/A2DP/AVDTP.hpp +++ b/module-bluetooth/Bluetooth/interface/profiles/A2DP/AVDTP.hpp @@ -19,15 +19,15 @@ namespace bluetooth struct SbcConfiguration { int reconfigure; + int numChannels; int samplingFrequency; - int channelMode; int blockLength; int subbands; - int allocationMethod; int minBitpoolValue; int maxBitpoolValue; - int framesPerBuffer; + btstack_sbc_channel_mode_t channelMode; + btstack_sbc_allocation_method_t allocationMethod; }; static SbcConfiguration sbcConfig; static btstack_sbc_encoder_state_t sbcEncoderState; diff --git a/module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp b/module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp index 7306a8b13af0502fba73297ae6a562ef313d3d22..d1cb6accc651b2b33b786b3667eef01be7bf7d6a 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp +++ b/module-bluetooth/Bluetooth/interface/profiles/GAP/GAP.cpp @@ -45,7 +45,7 @@ namespace bluetooth void GAP::stopScan() { - gap_inquiry_force_stop(); + gap_inquiry_stop(); devices.clear(); LOG_INFO("Scan stopped!"); } diff --git a/module-bluetooth/lib/btstack b/module-bluetooth/lib/btstack index 725ab2bc2adc415a0f50c5f34d85e24f5e22922d..1223a3ac01928bedc71480571472008a365bc42c 160000 --- a/module-bluetooth/lib/btstack +++ b/module-bluetooth/lib/btstack @@ -1 +1 @@ -Subproject commit 725ab2bc2adc415a0f50c5f34d85e24f5e22922d +Subproject commit 1223a3ac01928bedc71480571472008a365bc42c