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

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

Issue 2958393002: Add a simple, safe gain PostProcessor. (Closed)
Patch Set: Move cast_audio.json filepath string to a separate file Created 3 years, 6 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/saturated_gain.h
diff --git a/chromecast/media/cma/backend/alsa/post_processors/saturated_gain.h b/chromecast/media/cma/backend/alsa/post_processors/saturated_gain.h
new file mode 100644
index 0000000000000000000000000000000000000000..2419b4c7c054b645d66f48a0d6853f511666f236
--- /dev/null
+++ b/chromecast/media/cma/backend/alsa/post_processors/saturated_gain.h
@@ -0,0 +1,44 @@
+// 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_SATURATED_GAIN_H_
+#define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_SATURATED_GAIN_H_
+
+#include <memory>
+#include <vector>
kmackay 2017/06/30 17:59:38 <memory> and <vector> not used. #include <string>
bshaya 2017/07/06 21:04:45 Done.
+
+#include "base/macros.h"
+#include "chromecast/media/cma/backend/alsa/slew_volume.h"
+#include "chromecast/media/cma/backend/alsa/volume_map.h"
+#include "chromecast/public/media/audio_post_processor_shlib.h"
+
+namespace chromecast {
+namespace media {
+
+// Provides a simple gain, avoiding overflow.
+class SaturatedGain : public AudioPostProcessor {
+ public:
+ SaturatedGain(const std::string& config, int channels);
+ ~SaturatedGain() override;
+
+ // AudioPostProcessor implementation:
+ bool SetSampleRate(int sample_rate) override;
+ int ProcessFrames(float* data, int frames, float volume) override;
+ int GetRingingTimeInFrames() override;
+
+ private:
+ int channels_;
+ int sample_rate_;
+ float last_volume_;
+ VolumeMap volume_map_;
+ SlewVolume slew_volume_;
+ float gain_;
+
+ DISALLOW_COPY_AND_ASSIGN(SaturatedGain);
+};
+
+} // namespace media
+} // namespace chromecast
+
+#endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSORS_SATURATED_GAIN_H_

Powered by Google App Engine
This is Rietveld 408576698