AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
EqualizerController.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ACSDKEQUALIZERIMPLEMENTATIONS_EQUALIZERCONTROLLER_H_
17 #define ACSDKEQUALIZERIMPLEMENTATIONS_EQUALIZERCONTROLLER_H_
18 
19 #include <list>
20 #include <memory>
21 #include <mutex>
22 #include <set>
23 
30 
31 namespace alexaClientSDK {
32 namespace acsdkEqualizer {
33 
39 public:
43  ~EqualizerController() = default;
44 
54  static std::shared_ptr<EqualizerController> create(
55  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerModeControllerInterface> modeController,
56  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerConfigurationInterface> configuration,
57  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerStorageInterface> storage);
58 
67 
76  std::set<acsdkEqualizerInterfaces::EqualizerBand> bands);
77 
86 
96 
107 
114  void resetBands(const std::set<acsdkEqualizerInterfaces::EqualizerBand>& bands);
115 
122 
130 
137 
143  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerConfigurationInterface> getConfiguration();
144 
150  void registerEqualizer(std::shared_ptr<acsdkEqualizerInterfaces::EqualizerInterface> equalizer);
151 
157  void unregisterEqualizer(std::shared_ptr<acsdkEqualizerInterfaces::EqualizerInterface> equalizer);
158 
164  void addListener(std::shared_ptr<acsdkEqualizerInterfaces::EqualizerControllerListenerInterface> listener);
165 
171  void removeListener(std::shared_ptr<acsdkEqualizerInterfaces::EqualizerControllerListenerInterface> listener);
172 
173 private:
183  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerModeControllerInterface> modeController,
184  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerConfigurationInterface> configuration,
185  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerStorageInterface> storage);
186 
191  void updateState();
192 
201  void applyChangesToCurrentState(
203  std::function<int(int, int)> operation);
204 
211 
218  int truncateBandLevel(int level);
219 
225  void notifyListenersOnStateChanged(bool changed);
226 
228  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerModeControllerInterface> m_modeController;
229 
231  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerConfigurationInterface> m_configuration;
232 
234  std::shared_ptr<acsdkEqualizerInterfaces::EqualizerStorageInterface> m_storage;
235 
238 
240  std::mutex m_stateMutex;
241 
243  std::mutex m_modeMutex;
244 
246  std::list<std::shared_ptr<acsdkEqualizerInterfaces::EqualizerControllerListenerInterface>> m_listeners;
247 
249  std::list<std::shared_ptr<acsdkEqualizerInterfaces::EqualizerInterface>> m_equalizers;
250 };
251 
252 } // namespace acsdkEqualizer
253 } // namespace alexaClientSDK
254 
255 #endif // ACSDKEQUALIZERIMPLEMENTATIONS_EQUALIZERCONTROLLER_H_
std::unordered_map< EqualizerBand, int, avsCommon::utils::functional::EnumClassHash > EqualizerBandLevelMap
A collection of bands with their level values. This is an alias for EqualizerBand to band level (int)...
Definition: EqualizerTypes.h:77
Definition: EqualizerController.h:38
void adjustBandLevels(const acsdkEqualizerInterfaces::EqualizerBandLevelMap &bandAdjustmentMap)
std::shared_ptr< acsdkEqualizerInterfaces::EqualizerConfigurationInterface > getConfiguration()
void registerEqualizer(std::shared_ptr< acsdkEqualizerInterfaces::EqualizerInterface > equalizer)
acsdkEqualizerInterfaces::EqualizerMode getCurrentMode()
EqualizerBand
Definition: EqualizerTypes.h:32
void setCurrentMode(acsdkEqualizerInterfaces::EqualizerMode mode)
static std::shared_ptr< EqualizerController > create(std::shared_ptr< acsdkEqualizerInterfaces::EqualizerModeControllerInterface > modeController, std::shared_ptr< acsdkEqualizerInterfaces::EqualizerConfigurationInterface > configuration, std::shared_ptr< acsdkEqualizerInterfaces::EqualizerStorageInterface > storage)
avsCommon::utils::error::SuccessResult< int > getBandLevel(acsdkEqualizerInterfaces::EqualizerBand band)
void setBandLevels(const acsdkEqualizerInterfaces::EqualizerBandLevelMap &bandLevelMap)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void resetBands(const std::set< acsdkEqualizerInterfaces::EqualizerBand > &bands)
void removeListener(std::shared_ptr< acsdkEqualizerInterfaces::EqualizerControllerListenerInterface > listener)
void setBandLevel(acsdkEqualizerInterfaces::EqualizerBand band, int level)
void unregisterEqualizer(std::shared_ptr< acsdkEqualizerInterfaces::EqualizerInterface > equalizer)
EqualizerMode
Definition: EqualizerTypes.h:51
acsdkEqualizerInterfaces::EqualizerState getCurrentState()
avsCommon::utils::error::SuccessResult< acsdkEqualizerInterfaces::EqualizerBandLevelMap > getBandLevels(std::set< acsdkEqualizerInterfaces::EqualizerBand > bands)
void addListener(std::shared_ptr< acsdkEqualizerInterfaces::EqualizerControllerListenerInterface > listener)

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0