| Index: chromecast/media/cma/backend/alsa/post_processors/governor.cc
 | 
| diff --git a/chromecast/media/cma/backend/alsa/post_processors/governor_shlib.cc b/chromecast/media/cma/backend/alsa/post_processors/governor.cc
 | 
| similarity index 60%
 | 
| rename from chromecast/media/cma/backend/alsa/post_processors/governor_shlib.cc
 | 
| rename to chromecast/media/cma/backend/alsa/post_processors/governor.cc
 | 
| index e4af055ab791498943dbea720d6a73d93ecbd6ee..19ab8c784ad072c4cb822eb73df1a1086e59406c 100644
 | 
| --- a/chromecast/media/cma/backend/alsa/post_processors/governor_shlib.cc
 | 
| +++ b/chromecast/media/cma/backend/alsa/post_processors/governor.cc
 | 
| @@ -2,21 +2,22 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| +#include "chromecast/media/cma/backend/alsa/post_processors/governor.h"
 | 
| +
 | 
|  #include <memory>
 | 
|  #include <string>
 | 
|  
 | 
|  #include "base/logging.h"
 | 
| -#include "base/macros.h"
 | 
|  #include "base/values.h"
 | 
|  #include "chromecast/base/serializers.h"
 | 
|  #include "chromecast/media/cma/backend/alsa/slew_volume.h"
 | 
| -#include "chromecast/public/media/audio_post_processor_shlib.h"
 | 
|  
 | 
|  namespace chromecast {
 | 
|  namespace media {
 | 
|  
 | 
|  namespace {
 | 
|  const int kNoSampleRate = -1;
 | 
| +const int kNoVolume = -1;
 | 
|  
 | 
|  // Configuration strings:
 | 
|  const char kOnsetVolumeKey[] = "onset_volume";
 | 
| @@ -24,44 +25,17 @@ const char kClampMultiplierKey[] = "clamp_multiplier";
 | 
|  
 | 
|  }  // namespace
 | 
|  
 | 
| -// Provides a flat reduction in output volume if the input volume is above a
 | 
| -// given threshold.
 | 
| -// Used to protect speakers at high output levels
 | 
| -// while providing dyanmic range at low output level.
 | 
| -// The configuration string for this plugin is:
 | 
| -//  {"onset_volume": |VOLUME_TO_CLAMP|, "clamp_multiplier": |CLAMP_MULTIPLIER|}
 | 
| -// Input volumes > |VOLUME_TO_CLAMP| will be attenuated by |CLAMP_MULTIPLIER|.
 | 
| -class Governor : public AudioPostProcessor {
 | 
| - public:
 | 
| -  Governor(const std::string& config, int channels);
 | 
| -  ~Governor() override;
 | 
| -
 | 
| -  bool SetSampleRate(int sample_rate) override;
 | 
| -  int ProcessFrames(const std::vector<float*>& data,
 | 
| -                    int frames,
 | 
| -                    float volume) override;
 | 
| -  int GetRingingTimeInFrames() override;
 | 
| -
 | 
| - private:
 | 
| -  float GetGovernorMultiplier();
 | 
| -
 | 
| -  int channels_;
 | 
| -  int sample_rate_;
 | 
| -  float volume_;
 | 
| -  double onset_volume_;
 | 
| -  double clamp_multiplier_;
 | 
| -  SlewVolume governor_;
 | 
| -  DISALLOW_COPY_AND_ASSIGN(Governor);
 | 
| -};
 | 
| -
 | 
|  Governor::Governor(const std::string& config, int channels)
 | 
| -    : channels_(channels), sample_rate_(kNoSampleRate), volume_(1.0) {
 | 
| +    : channels_(channels),
 | 
| +      sample_rate_(kNoSampleRate),
 | 
| +      volume_(kNoVolume),
 | 
| +      slew_volume_() {
 | 
|    auto config_dict = base::DictionaryValue::From(DeserializeFromJson(config));
 | 
|    CHECK(config_dict) << "Governor config is not valid json: " << config;
 | 
|    CHECK(config_dict->GetDouble(kOnsetVolumeKey, &onset_volume_));
 | 
|    CHECK(config_dict->GetDouble(kClampMultiplierKey, &clamp_multiplier_));
 | 
|    DCHECK_EQ(channels_, 2);
 | 
| -  governor_.SetVolume(1.0);
 | 
| +  slew_volume_.SetVolume(1.0);
 | 
|    LOG(INFO) << "Created a governor: onset_volume = " << onset_volume_
 | 
|              << ", clamp_multiplier = " << clamp_multiplier_;
 | 
|  }
 | 
| @@ -70,7 +44,7 @@ Governor::~Governor() = default;
 | 
|  
 | 
|  bool Governor::SetSampleRate(int sample_rate) {
 | 
|    sample_rate_ = sample_rate;
 | 
| -  governor_.SetSampleRate(sample_rate);
 | 
| +  slew_volume_.SetSampleRate(sample_rate);
 | 
|    return true;
 | 
|  }
 | 
|  
 | 
| @@ -81,13 +55,13 @@ int Governor::ProcessFrames(const std::vector<float*>& data,
 | 
|  
 | 
|    if (volume != volume_) {
 | 
|      volume_ = volume;
 | 
| -    governor_.SetVolume(GetGovernorMultiplier());
 | 
| +    slew_volume_.SetVolume(GetGovernorMultiplier());
 | 
|    }
 | 
|  
 | 
|    for (int c = 0; c < channels_; ++c) {
 | 
|      DCHECK(data[c]);
 | 
| -    governor_.ProcessFMAC(c != 0 /* repeat_transition */, data[c], frames,
 | 
| -                          data[c]);
 | 
| +    slew_volume_.ProcessFMUL(c != 0 /* repeat_transition */, data[c], frames,
 | 
| +                             data[c]);
 | 
|    }
 | 
|  
 | 
|    return 0;  // No delay in this pipeline.
 | 
| @@ -104,6 +78,10 @@ float Governor::GetGovernorMultiplier() {
 | 
|    return 1.0;
 | 
|  }
 | 
|  
 | 
| +void Governor::SetSlewTimeMsForTest(int slew_time_ms) {
 | 
| +  slew_volume_.SetMaxSlewTimeMs(slew_time_ms);
 | 
| +}
 | 
| +
 | 
|  }  // namespace media
 | 
|  }  // namespace chromecast
 | 
|  
 | 
| 
 |