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

Unified Diff: chromecast/media/cma/backend/alsa/slew_volume.h

Issue 2341783004: [chromecast] Slew stream volume changes in StreamMixerAlsa. (Closed)
Patch Set: address comments Created 4 years, 3 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/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_

Powered by Google App Engine
This is Rietveld 408576698