OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "chromecast/media/cma/backend/alsa/slew_volume.h" |
| 13 #include "chromecast/public/media/audio_post_processor_shlib.h" |
| 14 |
| 15 namespace chromecast { |
| 16 namespace media { |
| 17 |
| 18 // Provides a flat reduction in output volume if the input volume is above a |
| 19 // given threshold. |
| 20 // Used to protect speakers at high output levels while providing dynamic range |
| 21 // at low output level. |
| 22 // The configuration string for this plugin is: |
| 23 // {"onset_volume": |VOLUME_TO_CLAMP|, "clamp_multiplier": |CLAMP_MULTIPLIER|} |
| 24 // Input volumes > |VOLUME_TO_CLAMP| will be attenuated by |CLAMP_MULTIPLIER|. |
| 25 class Governor : public AudioPostProcessor { |
| 26 public: |
| 27 Governor(const std::string& config, int channels); |
| 28 ~Governor() override; |
| 29 |
| 30 // AudioPostProcessor implementation: |
| 31 bool SetSampleRate(int sample_rate) override; |
| 32 int ProcessFrames(const std::vector<float*>& data, |
| 33 int frames, |
| 34 float volume) override; |
| 35 int GetRingingTimeInFrames() override; |
| 36 |
| 37 void SetSlewTimeMsForTest(int slew_time_ms); |
| 38 |
| 39 private: |
| 40 float GetGovernorMultiplier(); |
| 41 |
| 42 int channels_; |
| 43 int sample_rate_; |
| 44 float volume_; |
| 45 double onset_volume_; |
| 46 double clamp_multiplier_; |
| 47 SlewVolume slew_volume_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(Governor); |
| 50 }; |
| 51 |
| 52 } // namespace media |
| 53 } // namespace chromecast |
| 54 |
| 55 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_H_ |
OLD | NEW |