From 72b06448e1c9ecbbc415f7b63cbfe49400e48d2c Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Fri, 12 Aug 2022 10:40:15 +0200 Subject: [PATCH] [MOS-647][MOS-671] BT volume control fixes Set of fixes for Bluetooth volume control issues: * split OS volume from A2DP device volume; * added translations for additional popup required to indicate what volume is being set; * fixed issue that on some devices setting the lowest volume level would set the highest in reality; * fixed Bluetooth auto-turnoff functionality; * minor code cleanup. --- image/assets/lang/Deutsch.json | 1 + image/assets/lang/English.json | 3 +- image/assets/lang/Espanol.json | 1 + image/assets/lang/Francais.json | 1 + image/assets/lang/Polski.json | 1 + .../ApplicationCommonPopupBlueprints.cpp | 9 ++-- .../apps-common/popups/VolumeWindow.cpp | 44 +++++++++++++++---- .../apps-common/popups/VolumeWindow.hpp | 10 ++++- .../apps-common/popups/data/PopupData.hpp | 12 ++++- .../popups/data/PopupRequestParams.hpp | 12 ++++- module-audio/Audio/AudioCommon.hpp | 8 ++++ module-audio/Audio/VolumeScaler.cpp | 7 +-- module-audio/Audio/VolumeScaler.hpp | 7 +-- module-audio/Audio/test/unittest_scaler.cpp | 12 ----- .../puretx/PureTxAudioDeviceFactory.cpp | 10 +++-- .../Bluetooth/audio/BluetoothAudioDevice.cpp | 25 +++++++---- .../Bluetooth/audio/BluetoothAudioDevice.hpp | 11 +++-- .../interface/profiles/A2DP/A2DP.cpp | 34 +++++++------- .../interface/profiles/A2DP/AVRCP.cpp | 23 +++------- .../interface/profiles/A2DP/AVRCP.hpp | 1 + .../service-audio/ServiceAudio.cpp | 22 +++++----- .../include/service-audio/AudioMessage.hpp | 11 +++-- .../include/service-audio/ServiceAudio.hpp | 4 +- .../service-bluetooth/ServiceBluetooth.cpp | 10 ----- .../service-bluetooth/ServiceBluetooth.hpp | 1 - pure_changelog.md | 2 + 26 files changed, 163 insertions(+), 119 deletions(-) diff --git a/image/assets/lang/Deutsch.json b/image/assets/lang/Deutsch.json index 1885d4a1c8855863f37973a4c194f6f1523a2185..63409d238cee33aaede6bf2b592efc46b1af1cdc 100644 --- a/image/assets/lang/Deutsch.json +++ b/image/assets/lang/Deutsch.json @@ -301,6 +301,7 @@ "app_desktop_clear_all": "KPL.-LEER.", "app_desktop_replay": "ANTWORTEN", "app_popup_volume_text": "LAUTSTÄRKE", + "app_popup_bt_volume_text": "BLUETOOTH-LAUTSTÄRKE", "app_popup_music_volume_text": "MUSIKLAUTSTÄRKE", "app_popup_call_volume_text": "ANRUFLAUTSTÄRKE", "app_popup_muted_text": "STUMM", diff --git a/image/assets/lang/English.json b/image/assets/lang/English.json index 6d517fb53544c6b31bcaaf4b8d6d7ff9b967a830..2d898b461c8f6da4bfe12157b66141ef03cd5576 100644 --- a/image/assets/lang/English.json +++ b/image/assets/lang/English.json @@ -269,6 +269,7 @@ "app_desktop_clear_all": "CLEAR ALL", "app_desktop_replay": "REPLY", "app_popup_volume_text": "VOLUME", + "app_popup_bt_volume_text": "BLUETOOTH VOLUME", "app_popup_music_volume_text": "MUSIC VOLUME", "app_popup_call_volume_text": "CALL VOLUME", "app_popup_muted_text": "MUTED", @@ -481,7 +482,7 @@ "app_settings_option_connected": "CONNECTED", "app_settings_option_connected_audio": "CONNECTED AUDIO", "app_settings_option_connected_voice": "CONNECTED VOICE", - "app_settings_option_connected_both": "CONNECTED VOICE,AUDIO", + "app_settings_option_connected_both": "CONNECTED VOICE, AUDIO", "app_settings_option_connecting": "CONNECTING", "app_settings_option_pairing": "PAIRING", "app_settings_title_do_not_disturb": "Do not disturb", diff --git a/image/assets/lang/Espanol.json b/image/assets/lang/Espanol.json index a74a118912560b9ccdd39c18e3c2407ecbdb74c0..de7e3020f866cb60465dd9883211028e7e7b8be8 100644 --- a/image/assets/lang/Espanol.json +++ b/image/assets/lang/Espanol.json @@ -301,6 +301,7 @@ "app_desktop_clear_all": "BORRAR TODO", "app_desktop_replay": "RESPONDER", "app_popup_volume_text": "VOLUMEN", + "app_popup_bt_volume_text": "VOLUMEN DEL BLUETOOTH", "app_popup_music_volume_text": "VOLUMEN DE MÚSICA", "app_popup_call_volume_text": "VOLUMEN DE LLAMADAS", "app_popup_muted_text": "SILENCIADO", diff --git a/image/assets/lang/Francais.json b/image/assets/lang/Francais.json index b27ca3bc84a5229c61207e24b1e6d9ce7b6353b0..ce2aab1026d57ad2a1792d882d488952a98f5842 100644 --- a/image/assets/lang/Francais.json +++ b/image/assets/lang/Francais.json @@ -270,6 +270,7 @@ "app_desktop_clear_all": "TOUT EFFACER", "app_desktop_replay": "RÉPONDRE", "app_popup_volume_text": "VOLUME", + "app_popup_bt_volume_text": "VOLUME DE LA BLUETOOTH", "app_popup_music_volume_text": "VOLUME DE LA MUSIQUE", "app_popup_call_volume_text": "VOLUME D'APPEL", "app_popup_muted_text": "SILENCIEUX", diff --git a/image/assets/lang/Polski.json b/image/assets/lang/Polski.json index db300710e464c0b5d21f651f620d95b601c8e3b2..b975a3133539e2c8e31a92bdac897618656214bf 100644 --- a/image/assets/lang/Polski.json +++ b/image/assets/lang/Polski.json @@ -311,6 +311,7 @@ "app_desktop_clear_all": "WYCZYŚĆ", "app_desktop_replay": "ODPOWIEDZ", "app_popup_volume_text": "GŁOŚNOŚĆ", + "app_popup_bt_volume_text": "GŁOŚNOŚĆ BLUETOOTH", "app_popup_music_volume_text": "GŁOŚNOŚĆ MUZYKI", "app_popup_call_volume_text": "GŁOŚNOŚĆ POŁĄCZEŃ", "app_popup_muted_text": "WYCISZONE", diff --git a/module-apps/apps-common/ApplicationCommonPopupBlueprints.cpp b/module-apps/apps-common/ApplicationCommonPopupBlueprints.cpp index e2face32f6ff58320122d10991d83d277ae6bad9..e95a9d1101d1fb7217576461ac12610db7b09cb5 100644 --- a/module-apps/apps-common/ApplicationCommonPopupBlueprints.cpp +++ b/module-apps/apps-common/ApplicationCommonPopupBlueprints.cpp @@ -49,14 +49,15 @@ namespace app std::to_string(volumeParams->getVolume()).c_str()); auto volume = volumeParams->getVolume(); auto context = volumeParams->getAudioContext(); + auto source = volumeParams->getRequestSource(); + auto popupData = std::make_unique(volume, context, source); + const auto popupName = resolveWindowName(gui::popup::ID::Volume); if (const auto currentWindowName = getCurrentWindow()->getName(); currentWindowName == popupName) { - updateCurrentWindow(std::make_unique(volume, context)); + updateCurrentWindow(std::move(popupData)); } else { - switchWindowPopup(popupName, - volumeParams->getDisposition(), - std::make_unique(volume, context)); + switchWindowPopup(popupName, volumeParams->getDisposition(), std::move(popupData)); } return true; }); diff --git a/module-apps/apps-common/popups/VolumeWindow.cpp b/module-apps/apps-common/popups/VolumeWindow.cpp index 22cbd74be07c0fcea4237e960aef4a9b9e5e02f8..5a7f59147cb70e5898582975783f59ddd282fa71 100644 --- a/module-apps/apps-common/popups/VolumeWindow.cpp +++ b/module-apps/apps-common/popups/VolumeWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -55,21 +55,40 @@ namespace gui { WindowWithTimer::onBeforeShow(mode, data); const auto popupData = dynamic_cast(data); - if (popupData) { + if (popupData != nullptr) { volume = popupData->getVolume(); audioContext = popupData->getAudioContext(); + source = popupData->getVolumeChangeRequestSource(); if (volumeBar != nullptr) { volumeBar->setValue(volume); } if (volumeText != nullptr) { - showProperText(audioContext, volume); + showProperText(audioContext, volume, source); } } } - void VolumeWindow::showProperText(const audio::Context &audioContext, const audio::Volume volume) noexcept + void VolumeWindow::showProperText(const audio::Context &audioContext, + const audio::Volume volume, + const audio::VolumeChangeRequestSource source) noexcept { - volumeText->setText(utils::translate(style::window::volume::base_title_key)); + if (volume == 0) { + showMuted(); + return; + } + + switch (source) { + case audio::VolumeChangeRequestSource::A2DP: + showBTAudioDeviceVolume(); + return; + case audio::VolumeChangeRequestSource::HFP: + case audio::VolumeChangeRequestSource::HSP: + showCalling(); + return; + default: + break; + } + const auto [profileType, playbackType] = audioContext; if (playbackType == audio::PlaybackType::Multimedia) { showMultimediaPlayback(); @@ -81,12 +100,21 @@ namespace gui profileType == audio::Profile::Type::RoutingLoudspeaker) { showCalling(); } - - if (volume == 0) { - showMuted(); + else { + showBaseTitle(); } } + void VolumeWindow::showBaseTitle() noexcept + { + volumeText->setText(utils::translate(style::window::volume::base_title_key)); + } + + void VolumeWindow::showBTAudioDeviceVolume() noexcept + { + volumeText->setText(utils::translate(style::window::volume::bt_audio_title_key)); + } + void VolumeWindow::showMultimediaPlayback() noexcept { volumeText->setText(utils::translate(style::window::volume::music_title_key)); diff --git a/module-apps/apps-common/popups/VolumeWindow.hpp b/module-apps/apps-common/popups/VolumeWindow.hpp index 98946c48acf9de3aacf7036700cc43e21aa635b8..d373d69ab5b4cb61bbdfdfbaa8625290793afd8a 100644 --- a/module-apps/apps-common/popups/VolumeWindow.hpp +++ b/module-apps/apps-common/popups/VolumeWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -15,6 +15,7 @@ namespace style::window::volume { constexpr inline auto title_height = 33; constexpr inline auto base_title_key = "app_popup_volume_text"; + constexpr inline auto bt_audio_title_key = "app_popup_bt_volume_text"; constexpr inline auto music_title_key = "app_popup_music_volume_text"; constexpr inline auto call_title_key = "app_popup_call_volume_text"; constexpr inline auto mute_title_key = "app_popup_muted_text"; @@ -39,8 +40,13 @@ namespace gui private: audio::Volume volume = 0; audio::Context audioContext; + audio::VolumeChangeRequestSource source; - void showProperText(const audio::Context &audioContext, const audio::Volume volume) noexcept; + void showProperText(const audio::Context &audioContext, + audio::Volume volume, + audio::VolumeChangeRequestSource source) noexcept; + void showBaseTitle() noexcept; + void showBTAudioDeviceVolume() noexcept; void showMultimediaPlayback() noexcept; void showCalling() noexcept; void showMuted() noexcept; diff --git a/module-apps/apps-common/popups/data/PopupData.hpp b/module-apps/apps-common/popups/data/PopupData.hpp index f179e7fe518701e3548c27e80aa397c764f63119..6dba3b0dd303ec650d97775c797020e2330101c5 100644 --- a/module-apps/apps-common/popups/data/PopupData.hpp +++ b/module-apps/apps-common/popups/data/PopupData.hpp @@ -11,8 +11,10 @@ namespace gui class VolumePopupData : public SwitchData { public: - explicit VolumePopupData(const audio::Volume volume, const audio::Context audioContext) - : SwitchData(), volume{volume}, audioContext{audioContext} + explicit VolumePopupData(const audio::Volume volume, + const audio::Context audioContext, + audio::VolumeChangeRequestSource source) + : SwitchData(), volume{volume}, audioContext{audioContext}, source{source} {} [[nodiscard]] auto getVolume() const noexcept -> audio::Volume @@ -25,9 +27,15 @@ namespace gui return audioContext; } + [[nodiscard]] auto getVolumeChangeRequestSource() const noexcept -> audio::VolumeChangeRequestSource + { + return source; + } + private: const audio::Volume volume; const audio::Context audioContext; + const audio::VolumeChangeRequestSource source; }; class ModesPopupData : public SwitchData diff --git a/module-apps/apps-common/popups/data/PopupRequestParams.hpp b/module-apps/apps-common/popups/data/PopupRequestParams.hpp index 15e6eac0515fa0d788c16423849ea290d7def952..3aa432ec075b56d7ff088c30dcf44f8e296a0db7 100644 --- a/module-apps/apps-common/popups/data/PopupRequestParams.hpp +++ b/module-apps/apps-common/popups/data/PopupRequestParams.hpp @@ -146,8 +146,10 @@ namespace gui class VolumePopupRequestParams : public PopupRequestParams { public: - VolumePopupRequestParams(audio::Volume volume, const audio::Context audioContext) - : PopupRequestParams{gui::popup::ID::Volume}, volume{volume}, audioContext{audioContext} + VolumePopupRequestParams(audio::Volume volume, + const audio::Context audioContext, + audio::VolumeChangeRequestSource source) + : PopupRequestParams{gui::popup::ID::Volume}, volume{volume}, audioContext{audioContext}, source{source} {} [[nodiscard]] auto getVolume() const noexcept @@ -160,9 +162,15 @@ namespace gui return audioContext; } + [[nodiscard]] auto getRequestSource() const noexcept + { + return source; + } + private: const audio::Volume volume; const audio::Context audioContext; + const audio::VolumeChangeRequestSource source; }; } // namespace gui diff --git a/module-audio/Audio/AudioCommon.hpp b/module-audio/Audio/AudioCommon.hpp index 97610bc32ceba03385cd88a5a96100cfa525a7f4..031f3753613cec07f20196f91060b631a7d5d6e2 100644 --- a/module-audio/Audio/AudioCommon.hpp +++ b/module-audio/Audio/AudioCommon.hpp @@ -72,6 +72,14 @@ namespace audio Last = Bedtime, }; + enum class VolumeChangeRequestSource + { + A2DP, + HFP, + HSP, + Other + }; + /// Used to describe audio operations using Context = std::pair; diff --git a/module-audio/Audio/VolumeScaler.cpp b/module-audio/Audio/VolumeScaler.cpp index c0fa1ebf4eeeff4cd97ad19026bb08a579999e74..165f3e561f4d2d41d9f4741067000202802abf0b 100644 --- a/module-audio/Audio/VolumeScaler.cpp +++ b/module-audio/Audio/VolumeScaler.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "VolumeScaler.hpp" @@ -38,11 +38,6 @@ namespace audio::volume::scaler { return btProfileToSystemVolume(avrcpVolume, static_cast(avrcpMaxVolume)); } - - std::uint8_t toAvrcpVolume(float systemVolume) noexcept - { - return systemToBtProfileVolume(systemVolume, avrcpMaxVolume); - } } // namespace a2dp namespace hsp { diff --git a/module-audio/Audio/VolumeScaler.hpp b/module-audio/Audio/VolumeScaler.hpp index 4a700514b7f03d1f0d3d7fb6e24cc5b8724bf136..c48825eb24deef1c2e7748ab03438f8b2236cd91 100644 --- a/module-audio/Audio/VolumeScaler.hpp +++ b/module-audio/Audio/VolumeScaler.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -13,11 +13,6 @@ namespace audio::volume::scaler /// @param avrcpVolume - AVRCP volume level. /// @return Volume level scaled to satisfy system's range [audio::minVolume, audio::maxVolume]. Volume toSystemVolume(std::uint8_t avrcpVolume) noexcept; - /// @brief Takes volume level and converts it to according one for the AVRCP. - /// @param systemVolume - system volume level. - /// @return Volume level scaled to satisfy AVRCP's range [0, 127]. - std::uint8_t toAvrcpVolume(float systemVolume) noexcept; - } // namespace a2dp namespace hsp { diff --git a/module-audio/Audio/test/unittest_scaler.cpp b/module-audio/Audio/test/unittest_scaler.cpp index 2f1ab4b7e47ccf58828edf824bfe3f30e8065c6d..56cf70758c42859f2987e60903be3ecb6cdbb807 100644 --- a/module-audio/Audio/test/unittest_scaler.cpp +++ b/module-audio/Audio/test/unittest_scaler.cpp @@ -64,10 +64,6 @@ SCENARIO("Scale volume levels between system and bluetooth") { WHEN("Volume is set to 10") { - THEN("AVRCP volume is 127") - { - REQUIRE(audio::volume::scaler::a2dp::toAvrcpVolume(10) == std::uint8_t{127}); - } THEN("HSP speaker gain is 15") { REQUIRE(audio::volume::scaler::hsp::toHSPGain(10) == std::uint8_t{15}); @@ -75,10 +71,6 @@ SCENARIO("Scale volume levels between system and bluetooth") } WHEN("System volume is set to 7") { - THEN("AVRCP volume is 89") - { - REQUIRE(audio::volume::scaler::a2dp::toAvrcpVolume(7) == std::uint8_t{89}); - } THEN("HSP speaker gain is 7") { REQUIRE(audio::volume::scaler::hsp::toHSPGain(7) == std::uint8_t{11}); @@ -86,10 +78,6 @@ SCENARIO("Scale volume levels between system and bluetooth") } WHEN("System volume is set to 1") { - THEN("AVRCP volume is 13") - { - REQUIRE(audio::volume::scaler::a2dp::toAvrcpVolume(1) == std::uint8_t{13}); - } THEN("HSP speaker gain is 2") { REQUIRE(audio::volume::scaler::hsp::toHSPGain(1) == std::uint8_t{2}); diff --git a/module-audio/board/rt1051/puretx/PureTxAudioDeviceFactory.cpp b/module-audio/board/rt1051/puretx/PureTxAudioDeviceFactory.cpp index 03ca0bb80e4808d6edbd886458b5d8f25a8e56ce..8380b3262b97c2f6ef046b6a66d64dfe6490d1fa 100644 --- a/module-audio/board/rt1051/puretx/PureTxAudioDeviceFactory.cpp +++ b/module-audio/board/rt1051/puretx/PureTxAudioDeviceFactory.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "PureTxAudioDeviceFactory.hpp" @@ -16,21 +16,23 @@ using audio::RT1051CellularAudio; std::shared_ptr PureTxAudioDeviceFactory::getDevice(const audio::Profile &profile) { std::shared_ptr device; + const auto initialVolume = profile.GetOutputVolume(); + switch (profile.GetAudioDeviceType()) { case AudioDevice::Type::Audiocodec: { device = std::make_shared(profile.GetAudioConfiguration()); } break; case AudioDevice::Type::BluetoothA2DP: { - device = std::make_shared(); + device = std::make_shared(initialVolume); } break; case AudioDevice::Type::BluetoothHSP: { - device = std::make_shared(bluetooth::AudioProfile::HSP); + device = std::make_shared(initialVolume, bluetooth::AudioProfile::HSP); } break; case AudioDevice::Type::BluetoothHFP: { - device = std::make_shared(bluetooth::AudioProfile::HFP); + device = std::make_shared(initialVolume, bluetooth::AudioProfile::HFP); } break; case AudioDevice::Type::Cellular: { diff --git a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp index 39679a7105e88e379dce03bad0e5c5d2ba3fb05c..58c707cfaaed5e253ddd2ca1f8c5e67f99cb2851 100644 --- a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp +++ b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.cpp @@ -23,7 +23,9 @@ using bluetooth::CVSDAudioDevice; using namespace std::chrono_literals; BluetoothAudioDevice::BluetoothAudioDevice(AudioProfile audioProfile) : profile(audioProfile) -{} +{ + LOG_DEBUG("Creating bluetooth device with %s profile", magic_enum::enum_name(audioProfile).data()); +} BluetoothAudioDevice::~BluetoothAudioDevice() { @@ -52,13 +54,6 @@ auto BluetoothAudioDevice::isOutputEnabled() const -> bool auto A2DPAudioDevice::setOutputVolume(float vol) -> audio::AudioDevice::RetCode { - const auto volumeToSet = audio::volume::scaler::a2dp::toAvrcpVolume(vol); - const auto status = avrcp_controller_set_absolute_volume(AVRCP::mediaTracker.avrcp_cid, volumeToSet); - if (status != ERROR_CODE_SUCCESS) { - LOG_ERROR("Can't set volume level. Status %x", status); - return audio::AudioDevice::RetCode::Failure; - } - outputVolume = vol; return audio::AudioDevice::RetCode::Success; } @@ -234,7 +229,19 @@ auto BluetoothAudioDevice::fillSbcAudioBuffer() -> int audio::Stream::Span dataSpan; Sink::_stream->peek(dataSpan); - btstack_sbc_encoder_process_data(reinterpret_cast(dataSpan.data)); + + constexpr size_t bytesPerSample = + sizeof(std::int16_t) / sizeof(std::uint8_t); // Samples are signed 16-bit, but stored in uint8_t array + const float outputVolumeNormalized = + outputVolume / static_cast(audio::maxVolume); // Volume in <0;1> range + + std::int16_t *firstSample = reinterpret_cast(dataSpan.data); + std::int16_t *lastSample = firstSample + dataSpan.dataSize / bytesPerSample; + + /* Scale each sample to reduce volume */ + std::for_each(firstSample, lastSample, [&](std::int16_t &sample) { sample *= outputVolumeNormalized; }); + + btstack_sbc_encoder_process_data(firstSample); Sink::_stream->consume(); uint16_t sbcFrameSize = btstack_sbc_encoder_sbc_buffer_length(); diff --git a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp index 9dc443a7d06a2743566e815d877bd1fccd854391..b703a625853c9b72dd76cbe7dc8585b7bd17b268 100644 --- a/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp +++ b/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -48,8 +48,10 @@ namespace bluetooth class A2DPAudioDevice : public BluetoothAudioDevice { public: - explicit A2DPAudioDevice() : BluetoothAudioDevice(AudioProfile::A2DP) - {} + explicit A2DPAudioDevice(const float volume) : BluetoothAudioDevice(AudioProfile::A2DP) + { + outputVolume = volume; + } auto setOutputVolume(float vol) -> audio::AudioDevice::RetCode override; void onDataSend() override; @@ -65,8 +67,9 @@ namespace bluetooth class CVSDAudioDevice : public BluetoothAudioDevice { public: - explicit CVSDAudioDevice(const AudioProfile &profile) : BluetoothAudioDevice(profile) + explicit CVSDAudioDevice(const float volume, const AudioProfile &profile) : BluetoothAudioDevice(profile) { + outputVolume = volume; btstack_cvsd_plc_init(&cvsdPlcState); } diff --git a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp index 8410483fa21822285855736745b8e8fd4265f5dd..29c67c2b62e0612298df72ff8ec338ba31adb2bf 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp +++ b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include