Index: chromecast/media/cma/backend/alsa/slew_volume.h |
diff --git a/chromecast/media/cma/backend/alsa/slew_volume.h b/chromecast/media/cma/backend/alsa/slew_volume.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ab64298c59c14bd545471ed4b23dd2b56db32a04 |
--- /dev/null |
+++ b/chromecast/media/cma/backend/alsa/slew_volume.h |
@@ -0,0 +1,47 @@ |
+// Copyright 2016 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. |
+ |
+// Scale volume with slew rate limiting |
+ |
+#ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |
+#define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |
+ |
+#include <stdint.h> |
+ |
+#include "base/macros.h" |
+ |
+namespace chromecast { |
+namespace media { |
+ |
+class SlewVolume { |
+ public: |
+ SlewVolume(); |
+ SlewVolume(int max_slew_up_ms, int max_slew_down_ms); |
+ ~SlewVolume() = default; |
+ |
+ void SetSampleRate(int sample_rate); |
+ void SetVolume(double volume_scale); |
+ |
+ // Assumes 1 channel float data. Smoothly calculates |
+ // dest[i] += src[i] * volume_scaling |
+ void ProcessFMAC(const float* src, int frames, float* dest); |
+ |
+ // Assumes 2 channels. |
+ bool ProcessInterleaved(int32_t* data, int frames); |
+ |
+ private: |
+ double volume_scale_ = 1.0; |
+ double current_volume_ = 1.0; |
+ int max_slew_time_up_ms_; |
+ int max_slew_time_down_ms_; |
+ double max_slew_up_; |
+ double max_slew_down_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SlewVolume); |
+}; |
+ |
+} // namespace media |
+} // namespace chromecast |
+ |
+#endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |