Loading system/btif/co/bta_av_co.cc +13 −11 Original line number Original line Diff line number Diff line Loading @@ -489,8 +489,8 @@ void BtaAvCo::ProcessSetConfig(tBTA_AV_HNDL bta_av_handle, const RawAddress& pee if (t_local_sep == AVDT_TSEP_SRC) { if (t_local_sep == AVDT_TSEP_SRC) { log::verbose("peer {} is A2DP SINK", p_peer->addr); log::verbose("peer {} is A2DP SINK", p_peer->addr); if ((p_peer->GetCodecs() == nullptr) || if ((p_peer->GetCodecs() == nullptr) || !SetCodecOtaConfig(p_peer, p_codec_info, num_protect, p_protect_info, SetCodecOtaConfig(p_peer, p_codec_info, num_protect, p_protect_info, t_local_sep) != t_local_sep)) { A2DP_SUCCESS) { log::error("cannot set source codec {} for peer {}", A2DP_CodecName(p_codec_info), log::error("cannot set source codec {} for peer {}", A2DP_CodecName(p_codec_info), p_peer->addr); p_peer->addr); } else { } else { Loading Loading @@ -1329,7 +1329,7 @@ BtaAvCoState* BtaAvCo::getStateFromPeer(const BtaAvCoPeer* p_peer) { } } } } bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, tA2DP_STATUS BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, uint8_t num_protect, const uint8_t* p_protect_info, uint8_t num_protect, const uint8_t* p_protect_info, const uint8_t t_local_sep) { const uint8_t t_local_sep) { uint8_t result_codec_config[AVDT_CODEC_SIZE]; uint8_t result_codec_config[AVDT_CODEC_SIZE]; Loading @@ -1347,15 +1347,17 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_ // We have all the information we need from the peer, so we can // We have all the information we need from the peer, so we can // proceed with the OTA codec configuration. // proceed with the OTA codec configuration. log::error("peer {} : cannot find peer SEP to configure", p_peer->addr); log::error("peer {} : cannot find peer SEP to configure", p_peer->addr); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } tA2DP_ENCODER_INIT_PEER_PARAMS peer_params; tA2DP_ENCODER_INIT_PEER_PARAMS peer_params; GetPeerEncoderParameters(p_peer->addr, &peer_params); GetPeerEncoderParameters(p_peer->addr, &peer_params); if (!p_peer->GetCodecs()->setCodecOtaConfig(p_ota_codec_config, &peer_params, result_codec_config, auto status = p_peer->GetCodecs()->setCodecOtaConfig(p_ota_codec_config, &peer_params, &restart_input, &restart_output, &config_updated)) { result_codec_config, &restart_input, log::error("peer {} : cannot set OTA config", p_peer->addr); &restart_output, &config_updated); return false; if (status != A2DP_SUCCESS) { log::error("peer {} : cannot set OTA config, status: 0x{:x}", p_peer->addr, status); return status; } } if (restart_output) { if (restart_output) { Loading @@ -1371,7 +1373,7 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_ ReportSourceCodecState(p_peer); ReportSourceCodecState(p_peer); } } return true; return A2DP_SUCCESS; } } void bta_av_co_init(const std::vector<btav_a2dp_codec_config_t>& codec_priorities, void bta_av_co_init(const std::vector<btav_a2dp_codec_config_t>& codec_priorities, Loading system/btif/include/bta_av_co.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -452,7 +452,7 @@ private: * @param t_local_sep the profile for which ota config needs to be set. * @param t_local_sep the profile for which ota config needs to be set. * @return true on success, otherwise false * @return true on success, otherwise false */ */ bool SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, tA2DP_STATUS SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, uint8_t num_protect, const uint8_t* p_protect_info, uint8_t num_protect, const uint8_t* p_protect_info, const uint8_t t_local_sep); const uint8_t t_local_sep); Loading system/stack/a2dp/a2dp_codec_config.cc +31 −23 Original line number Original line Diff line number Diff line Loading @@ -330,11 +330,11 @@ bool A2dpCodecConfig::isCodecConfigEmpty(const btav_a2dp_codec_config_t& codec_c (codec_config.codec_specific_3 == 0) && (codec_config.codec_specific_4 == 0); (codec_config.codec_specific_3 == 0) && (codec_config.codec_specific_4 == 0); } } bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, tA2DP_STATUS A2dpCodecConfig::setCodecUserConfig( const btav_a2dp_codec_config_t& codec_user_config, const btav_a2dp_codec_config_t& codec_audio_config, const btav_a2dp_codec_config_t& codec_audio_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const uint8_t* p_peer_codec_info, const uint8_t* p_peer_codec_info, bool is_capability, bool is_capability, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated) { bool* p_restart_output, bool* p_config_updated) { std::lock_guard<std::recursive_mutex> lock(codec_mutex_); std::lock_guard<std::recursive_mutex> lock(codec_mutex_); *p_restart_input = false; *p_restart_input = false; Loading @@ -356,7 +356,7 @@ bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_u // Restore the local copy of the user and audio config // Restore the local copy of the user and audio config codec_user_config_ = saved_codec_user_config; codec_user_config_ = saved_codec_user_config; codec_audio_config_ = saved_codec_audio_config; codec_audio_config_ = saved_codec_audio_config; return false; return status; } } // // Loading @@ -381,7 +381,7 @@ bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_u *p_config_updated = true; *p_config_updated = true; } } return true; return A2DP_SUCCESS; } } bool A2dpCodecConfig::codecConfigIsValid(const btav_a2dp_codec_config_t& codec_config) { bool A2dpCodecConfig::codecConfigIsValid(const btav_a2dp_codec_config_t& codec_config) { Loading Loading @@ -781,9 +781,10 @@ bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_c // Reuse the existing codec audio config // Reuse the existing codec audio config codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, if (a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, p_peer_sink_capabilities, true, p_result_codec_config, p_peer_sink_capabilities, true, p_result_codec_config, p_restart_input, p_restart_output, p_config_updated)) { p_restart_input, p_restart_output, p_config_updated) != A2DP_SUCCESS) { goto fail; goto fail; } } Loading Loading @@ -875,16 +876,17 @@ bool A2dpCodecs::setCodecAudioConfig(const btav_a2dp_codec_config_t& codec_audio // Reuse the existing codec user config // Reuse the existing codec user config codec_user_config = a2dp_codec_config->getCodecUserConfig(); codec_user_config = a2dp_codec_config->getCodecUserConfig(); bool restart_input = false; // Flag ignored - input was just restarted bool restart_input = false; // Flag ignored - input was just restarted if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, if (a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, p_peer_sink_capabilities, true, p_result_codec_config, p_peer_sink_capabilities, true, p_result_codec_config, &restart_input, p_restart_output, p_config_updated)) { &restart_input, p_restart_output, p_config_updated) != A2DP_SUCCESS) { return false; return false; } } return true; return true; } } bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, tA2DP_STATUS A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated) { bool* p_restart_output, bool* p_config_updated) { Loading @@ -897,6 +899,7 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, *p_restart_input = false; *p_restart_input = false; *p_restart_output = false; *p_restart_output = false; *p_config_updated = false; *p_config_updated = false; tA2DP_STATUS status = AVDTP_UNSUPPORTED_CONFIGURATION; // Check whether the current codec config is explicitly configured by // Check whether the current codec config is explicitly configured by // user configuration. If yes, then the OTA codec configuration is ignored. // user configuration. If yes, then the OTA codec configuration is ignored. Loading @@ -923,11 +926,13 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, if (iter == indexed_codecs_.end()) { if (iter == indexed_codecs_.end()) { log::warn("cannot find codec configuration for peer OTA codec {}", log::warn("cannot find codec configuration for peer OTA codec {}", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); status = A2DP_NOT_SUPPORTED_CODEC_TYPE; goto fail; goto fail; } } a2dp_codec_config = iter->second; a2dp_codec_config = iter->second; } } if (a2dp_codec_config == nullptr) { if (a2dp_codec_config == nullptr) { status = A2DP_NOT_SUPPORTED_CODEC_TYPE; goto fail; goto fail; } } codec_user_config = a2dp_codec_config->getCodecUserConfig(); codec_user_config = a2dp_codec_config->getCodecUserConfig(); Loading @@ -936,19 +941,22 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, "ignoring peer OTA configuration for codec {}: existing user " "ignoring peer OTA configuration for codec {}: existing user " "configuration for same codec", "configuration for same codec", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); status = AVDTP_UNSUPPORTED_CONFIGURATION; goto fail; goto fail; } } current_codec_config_ = a2dp_codec_config; current_codec_config_ = a2dp_codec_config; // Reuse the existing codec user config and codec audio config // Reuse the existing codec user config and codec audio config codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, status = a2dp_codec_config->setCodecUserConfig( p_ota_codec_config, false, p_result_codec_config, codec_user_config, codec_audio_config, p_peer_params, p_ota_codec_config, false, p_restart_input, p_restart_output, p_config_updated)) { p_result_codec_config, p_restart_input, p_restart_output, p_config_updated); if (status != A2DP_SUCCESS) { log::warn("cannot set codec configuration for peer OTA codec {}", log::warn("cannot set codec configuration for peer OTA codec {}", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); goto fail; goto fail; } } log::assert_that(current_codec_config_ != nullptr, log::assert_that(current_codec_config_ != nullptr, "assert failed: current_codec_config_ != nullptr"); "assert failed: current_codec_config_ != nullptr"); Loading @@ -956,11 +964,11 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, *p_config_updated = true; *p_config_updated = true; } } return true; return A2DP_SUCCESS; fail: fail: current_codec_config_ = last_codec_config; current_codec_config_ = last_codec_config; return false; return status; } } bool A2dpCodecs::setPeerSinkCodecCapabilities(const uint8_t* p_peer_codec_capabilities) { bool A2dpCodecs::setPeerSinkCodecCapabilities(const uint8_t* p_peer_codec_capabilities) { Loading system/stack/include/a2dp_codec_api.h +10 −10 Original line number Original line Diff line number Diff line Loading @@ -183,7 +183,7 @@ protected: // If there is any change in the codec configuration, flag |p_config_updated| // If there is any change in the codec configuration, flag |p_config_updated| // is set to true. // is set to true. // Returns true on success, otherwise false. // Returns true on success, otherwise false. bool setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, tA2DP_STATUS setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, const btav_a2dp_codec_config_t& codec_audio_config, const btav_a2dp_codec_config_t& codec_audio_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const uint8_t* p_peer_codec_info, bool is_capability, const uint8_t* p_peer_codec_info, bool is_capability, Loading Loading @@ -410,7 +410,7 @@ public: // If there is any change in the codec configuration, flag |p_config_updated| // If there is any change in the codec configuration, flag |p_config_updated| // is set to true. // is set to true. // Returns true on success, otherwise false. // Returns true on success, otherwise false. bool setCodecOtaConfig(const uint8_t* p_ota_codec_config, tA2DP_STATUS setCodecOtaConfig(const uint8_t* p_ota_codec_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated); bool* p_restart_output, bool* p_config_updated); Loading system/test/mock/mock_stack_a2dp_codec_config.cc +14 −15 Original line number Original line Diff line number Diff line Loading @@ -124,16 +124,15 @@ bool A2dpCodecConfig::isCodecConfigEmpty(const btav_a2dp_codec_config_t& /* code inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return false; } } bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, tA2DP_STATUS A2dpCodecConfig::setCodecUserConfig( const btav_a2dp_codec_config_t& /* codec_user_config */, const btav_a2dp_codec_config_t& /* codec_audio_config */, const btav_a2dp_codec_config_t& /* codec_audio_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const uint8_t* /* p_peer_codec_info */, const uint8_t* /* p_peer_codec_info */, bool /* is_capability */, bool /* is_capability */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_input */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_output */, bool* /* p_config_updated */) { bool* /* p_restart_input */, bool* /* p_restart_output */, bool* /* p_config_updated */) { inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } bool A2dpCodecs::getCodecConfigAndCapabilities( bool A2dpCodecs::getCodecConfigAndCapabilities( btav_a2dp_codec_config_t* /* p_codec_config */, btav_a2dp_codec_config_t* /* p_codec_config */, Loading Loading @@ -164,13 +163,13 @@ bool A2dpCodecs::setCodecConfig(const uint8_t* /* p_peer_codec_info */, bool /* inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return false; } } bool A2dpCodecs::setCodecOtaConfig(const uint8_t* /* p_ota_codec_config */, tA2DP_STATUS A2dpCodecs::setCodecOtaConfig( const uint8_t* /* p_ota_codec_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, uint8_t* /* p_result_codec_config */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_input */, bool* /* p_restart_input */, bool* /* p_restart_output */, bool* /* p_restart_output */, bool* /* p_config_updated */) { bool* /* p_config_updated */) { inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, Loading Loading
system/btif/co/bta_av_co.cc +13 −11 Original line number Original line Diff line number Diff line Loading @@ -489,8 +489,8 @@ void BtaAvCo::ProcessSetConfig(tBTA_AV_HNDL bta_av_handle, const RawAddress& pee if (t_local_sep == AVDT_TSEP_SRC) { if (t_local_sep == AVDT_TSEP_SRC) { log::verbose("peer {} is A2DP SINK", p_peer->addr); log::verbose("peer {} is A2DP SINK", p_peer->addr); if ((p_peer->GetCodecs() == nullptr) || if ((p_peer->GetCodecs() == nullptr) || !SetCodecOtaConfig(p_peer, p_codec_info, num_protect, p_protect_info, SetCodecOtaConfig(p_peer, p_codec_info, num_protect, p_protect_info, t_local_sep) != t_local_sep)) { A2DP_SUCCESS) { log::error("cannot set source codec {} for peer {}", A2DP_CodecName(p_codec_info), log::error("cannot set source codec {} for peer {}", A2DP_CodecName(p_codec_info), p_peer->addr); p_peer->addr); } else { } else { Loading Loading @@ -1329,7 +1329,7 @@ BtaAvCoState* BtaAvCo::getStateFromPeer(const BtaAvCoPeer* p_peer) { } } } } bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, tA2DP_STATUS BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, uint8_t num_protect, const uint8_t* p_protect_info, uint8_t num_protect, const uint8_t* p_protect_info, const uint8_t t_local_sep) { const uint8_t t_local_sep) { uint8_t result_codec_config[AVDT_CODEC_SIZE]; uint8_t result_codec_config[AVDT_CODEC_SIZE]; Loading @@ -1347,15 +1347,17 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_ // We have all the information we need from the peer, so we can // We have all the information we need from the peer, so we can // proceed with the OTA codec configuration. // proceed with the OTA codec configuration. log::error("peer {} : cannot find peer SEP to configure", p_peer->addr); log::error("peer {} : cannot find peer SEP to configure", p_peer->addr); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } tA2DP_ENCODER_INIT_PEER_PARAMS peer_params; tA2DP_ENCODER_INIT_PEER_PARAMS peer_params; GetPeerEncoderParameters(p_peer->addr, &peer_params); GetPeerEncoderParameters(p_peer->addr, &peer_params); if (!p_peer->GetCodecs()->setCodecOtaConfig(p_ota_codec_config, &peer_params, result_codec_config, auto status = p_peer->GetCodecs()->setCodecOtaConfig(p_ota_codec_config, &peer_params, &restart_input, &restart_output, &config_updated)) { result_codec_config, &restart_input, log::error("peer {} : cannot set OTA config", p_peer->addr); &restart_output, &config_updated); return false; if (status != A2DP_SUCCESS) { log::error("peer {} : cannot set OTA config, status: 0x{:x}", p_peer->addr, status); return status; } } if (restart_output) { if (restart_output) { Loading @@ -1371,7 +1373,7 @@ bool BtaAvCo::SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_ ReportSourceCodecState(p_peer); ReportSourceCodecState(p_peer); } } return true; return A2DP_SUCCESS; } } void bta_av_co_init(const std::vector<btav_a2dp_codec_config_t>& codec_priorities, void bta_av_co_init(const std::vector<btav_a2dp_codec_config_t>& codec_priorities, Loading
system/btif/include/bta_av_co.h +3 −3 Original line number Original line Diff line number Diff line Loading @@ -452,7 +452,7 @@ private: * @param t_local_sep the profile for which ota config needs to be set. * @param t_local_sep the profile for which ota config needs to be set. * @return true on success, otherwise false * @return true on success, otherwise false */ */ bool SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, tA2DP_STATUS SetCodecOtaConfig(BtaAvCoPeer* p_peer, const uint8_t* p_ota_codec_config, uint8_t num_protect, const uint8_t* p_protect_info, uint8_t num_protect, const uint8_t* p_protect_info, const uint8_t t_local_sep); const uint8_t t_local_sep); Loading
system/stack/a2dp/a2dp_codec_config.cc +31 −23 Original line number Original line Diff line number Diff line Loading @@ -330,11 +330,11 @@ bool A2dpCodecConfig::isCodecConfigEmpty(const btav_a2dp_codec_config_t& codec_c (codec_config.codec_specific_3 == 0) && (codec_config.codec_specific_4 == 0); (codec_config.codec_specific_3 == 0) && (codec_config.codec_specific_4 == 0); } } bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, tA2DP_STATUS A2dpCodecConfig::setCodecUserConfig( const btav_a2dp_codec_config_t& codec_user_config, const btav_a2dp_codec_config_t& codec_audio_config, const btav_a2dp_codec_config_t& codec_audio_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const uint8_t* p_peer_codec_info, const uint8_t* p_peer_codec_info, bool is_capability, bool is_capability, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated) { bool* p_restart_output, bool* p_config_updated) { std::lock_guard<std::recursive_mutex> lock(codec_mutex_); std::lock_guard<std::recursive_mutex> lock(codec_mutex_); *p_restart_input = false; *p_restart_input = false; Loading @@ -356,7 +356,7 @@ bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_u // Restore the local copy of the user and audio config // Restore the local copy of the user and audio config codec_user_config_ = saved_codec_user_config; codec_user_config_ = saved_codec_user_config; codec_audio_config_ = saved_codec_audio_config; codec_audio_config_ = saved_codec_audio_config; return false; return status; } } // // Loading @@ -381,7 +381,7 @@ bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_u *p_config_updated = true; *p_config_updated = true; } } return true; return A2DP_SUCCESS; } } bool A2dpCodecConfig::codecConfigIsValid(const btav_a2dp_codec_config_t& codec_config) { bool A2dpCodecConfig::codecConfigIsValid(const btav_a2dp_codec_config_t& codec_config) { Loading Loading @@ -781,9 +781,10 @@ bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_c // Reuse the existing codec audio config // Reuse the existing codec audio config codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, if (a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, p_peer_sink_capabilities, true, p_result_codec_config, p_peer_sink_capabilities, true, p_result_codec_config, p_restart_input, p_restart_output, p_config_updated)) { p_restart_input, p_restart_output, p_config_updated) != A2DP_SUCCESS) { goto fail; goto fail; } } Loading Loading @@ -875,16 +876,17 @@ bool A2dpCodecs::setCodecAudioConfig(const btav_a2dp_codec_config_t& codec_audio // Reuse the existing codec user config // Reuse the existing codec user config codec_user_config = a2dp_codec_config->getCodecUserConfig(); codec_user_config = a2dp_codec_config->getCodecUserConfig(); bool restart_input = false; // Flag ignored - input was just restarted bool restart_input = false; // Flag ignored - input was just restarted if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, if (a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, p_peer_sink_capabilities, true, p_result_codec_config, p_peer_sink_capabilities, true, p_result_codec_config, &restart_input, p_restart_output, p_config_updated)) { &restart_input, p_restart_output, p_config_updated) != A2DP_SUCCESS) { return false; return false; } } return true; return true; } } bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, tA2DP_STATUS A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated) { bool* p_restart_output, bool* p_config_updated) { Loading @@ -897,6 +899,7 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, *p_restart_input = false; *p_restart_input = false; *p_restart_output = false; *p_restart_output = false; *p_config_updated = false; *p_config_updated = false; tA2DP_STATUS status = AVDTP_UNSUPPORTED_CONFIGURATION; // Check whether the current codec config is explicitly configured by // Check whether the current codec config is explicitly configured by // user configuration. If yes, then the OTA codec configuration is ignored. // user configuration. If yes, then the OTA codec configuration is ignored. Loading @@ -923,11 +926,13 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, if (iter == indexed_codecs_.end()) { if (iter == indexed_codecs_.end()) { log::warn("cannot find codec configuration for peer OTA codec {}", log::warn("cannot find codec configuration for peer OTA codec {}", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); status = A2DP_NOT_SUPPORTED_CODEC_TYPE; goto fail; goto fail; } } a2dp_codec_config = iter->second; a2dp_codec_config = iter->second; } } if (a2dp_codec_config == nullptr) { if (a2dp_codec_config == nullptr) { status = A2DP_NOT_SUPPORTED_CODEC_TYPE; goto fail; goto fail; } } codec_user_config = a2dp_codec_config->getCodecUserConfig(); codec_user_config = a2dp_codec_config->getCodecUserConfig(); Loading @@ -936,19 +941,22 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, "ignoring peer OTA configuration for codec {}: existing user " "ignoring peer OTA configuration for codec {}: existing user " "configuration for same codec", "configuration for same codec", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); status = AVDTP_UNSUPPORTED_CONFIGURATION; goto fail; goto fail; } } current_codec_config_ = a2dp_codec_config; current_codec_config_ = a2dp_codec_config; // Reuse the existing codec user config and codec audio config // Reuse the existing codec user config and codec audio config codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); codec_audio_config = a2dp_codec_config->getCodecAudioConfig(); if (!a2dp_codec_config->setCodecUserConfig(codec_user_config, codec_audio_config, p_peer_params, status = a2dp_codec_config->setCodecUserConfig( p_ota_codec_config, false, p_result_codec_config, codec_user_config, codec_audio_config, p_peer_params, p_ota_codec_config, false, p_restart_input, p_restart_output, p_config_updated)) { p_result_codec_config, p_restart_input, p_restart_output, p_config_updated); if (status != A2DP_SUCCESS) { log::warn("cannot set codec configuration for peer OTA codec {}", log::warn("cannot set codec configuration for peer OTA codec {}", A2DP_CodecName(p_ota_codec_config)); A2DP_CodecName(p_ota_codec_config)); goto fail; goto fail; } } log::assert_that(current_codec_config_ != nullptr, log::assert_that(current_codec_config_ != nullptr, "assert failed: current_codec_config_ != nullptr"); "assert failed: current_codec_config_ != nullptr"); Loading @@ -956,11 +964,11 @@ bool A2dpCodecs::setCodecOtaConfig(const uint8_t* p_ota_codec_config, *p_config_updated = true; *p_config_updated = true; } } return true; return A2DP_SUCCESS; fail: fail: current_codec_config_ = last_codec_config; current_codec_config_ = last_codec_config; return false; return status; } } bool A2dpCodecs::setPeerSinkCodecCapabilities(const uint8_t* p_peer_codec_capabilities) { bool A2dpCodecs::setPeerSinkCodecCapabilities(const uint8_t* p_peer_codec_capabilities) { Loading
system/stack/include/a2dp_codec_api.h +10 −10 Original line number Original line Diff line number Diff line Loading @@ -183,7 +183,7 @@ protected: // If there is any change in the codec configuration, flag |p_config_updated| // If there is any change in the codec configuration, flag |p_config_updated| // is set to true. // is set to true. // Returns true on success, otherwise false. // Returns true on success, otherwise false. bool setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, tA2DP_STATUS setCodecUserConfig(const btav_a2dp_codec_config_t& codec_user_config, const btav_a2dp_codec_config_t& codec_audio_config, const btav_a2dp_codec_config_t& codec_audio_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const uint8_t* p_peer_codec_info, bool is_capability, const uint8_t* p_peer_codec_info, bool is_capability, Loading Loading @@ -410,7 +410,7 @@ public: // If there is any change in the codec configuration, flag |p_config_updated| // If there is any change in the codec configuration, flag |p_config_updated| // is set to true. // is set to true. // Returns true on success, otherwise false. // Returns true on success, otherwise false. bool setCodecOtaConfig(const uint8_t* p_ota_codec_config, tA2DP_STATUS setCodecOtaConfig(const uint8_t* p_ota_codec_config, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, const tA2DP_ENCODER_INIT_PEER_PARAMS* p_peer_params, uint8_t* p_result_codec_config, bool* p_restart_input, uint8_t* p_result_codec_config, bool* p_restart_input, bool* p_restart_output, bool* p_config_updated); bool* p_restart_output, bool* p_config_updated); Loading
system/test/mock/mock_stack_a2dp_codec_config.cc +14 −15 Original line number Original line Diff line number Diff line Loading @@ -124,16 +124,15 @@ bool A2dpCodecConfig::isCodecConfigEmpty(const btav_a2dp_codec_config_t& /* code inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return false; } } bool A2dpCodecConfig::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, tA2DP_STATUS A2dpCodecConfig::setCodecUserConfig( const btav_a2dp_codec_config_t& /* codec_user_config */, const btav_a2dp_codec_config_t& /* codec_audio_config */, const btav_a2dp_codec_config_t& /* codec_audio_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const uint8_t* /* p_peer_codec_info */, const uint8_t* /* p_peer_codec_info */, bool /* is_capability */, bool /* is_capability */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_input */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_output */, bool* /* p_config_updated */) { bool* /* p_restart_input */, bool* /* p_restart_output */, bool* /* p_config_updated */) { inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } bool A2dpCodecs::getCodecConfigAndCapabilities( bool A2dpCodecs::getCodecConfigAndCapabilities( btav_a2dp_codec_config_t* /* p_codec_config */, btav_a2dp_codec_config_t* /* p_codec_config */, Loading Loading @@ -164,13 +163,13 @@ bool A2dpCodecs::setCodecConfig(const uint8_t* /* p_peer_codec_info */, bool /* inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return false; } } bool A2dpCodecs::setCodecOtaConfig(const uint8_t* /* p_ota_codec_config */, tA2DP_STATUS A2dpCodecs::setCodecOtaConfig( const uint8_t* /* p_ota_codec_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, uint8_t* /* p_result_codec_config */, uint8_t* /* p_result_codec_config */, bool* /* p_restart_input */, bool* /* p_restart_input */, bool* /* p_restart_output */, bool* /* p_restart_output */, bool* /* p_config_updated */) { bool* /* p_config_updated */) { inc_func_call_count(__func__); inc_func_call_count(__func__); return false; return AVDTP_UNSUPPORTED_CONFIGURATION; } } bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, bool A2dpCodecs::setCodecUserConfig(const btav_a2dp_codec_config_t& /* codec_user_config */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, const tA2DP_ENCODER_INIT_PEER_PARAMS* /* p_peer_params */, Loading