Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: chromecast/media/cma/backend/alsa/post_processors/governor_shlib.h

Issue 2860673003: [Chromecast] Correct libcast_governor behavior. (Closed)
Patch Set: Add SlewVolume unittests. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/media/cma/backend/alsa/post_processors/governor_shlib.h
diff --git a/chromecast/media/cma/backend/alsa/post_processors/governor_shlib.h b/chromecast/media/cma/backend/alsa/post_processors/governor_shlib.h
new file mode 100644
index 0000000000000000000000000000000000000000..29ebaccc846fcf93e7c0381b007c8e51e1dc1531
--- /dev/null
+++ b/chromecast/media/cma/backend/alsa/post_processors/governor_shlib.h
@@ -0,0 +1,54 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_SHLIB_H_
+#define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_SHLIB_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/macros.h"
+#include "chromecast/public/media/audio_post_processor_shlib.h"
+
+namespace chromecast {
+namespace media {
+
+class SlewVolume;
+
+// 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;
+
bcf 2017/05/04 03:45:06 // AudioPostProcessor implementation: Add overrid
bshaya 2017/05/04 18:15:41 Done.
+ bool SetSampleRate(int sample_rate) override;
+ int ProcessFrames(const std::vector<float*>& data,
+ int frames,
+ float volume) override;
+ int GetRingingTimeInFrames() override;
+
+ void SetSlewTimeMsForTest(int slew_time_ms);
+
+ private:
+ float GetGovernorMultiplier();
+
+ int channels_;
+ int sample_rate_;
+ float volume_;
+ double onset_volume_;
+ double clamp_multiplier_;
+ std::unique_ptr<SlewVolume> slew_volume_;
bcf 2017/05/04 03:45:06 ptr necessary? Can we just have SlewVolume inside?
bshaya 2017/05/04 18:15:41 Done.
+ DISALLOW_COPY_AND_ASSIGN(Governor);
+};
+
+} // namespace media
+} // namespace chromecast
+
+#endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_GOVERNOR_SHLIB_H_

Powered by Google App Engine
This is Rietveld 408576698