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

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

Issue 2341783004: [chromecast] Slew stream volume changes in StreamMixerAlsa. (Closed)
Patch Set: 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..0d222b26261848f4cfa99450961d1a9303b2ff2a
--- /dev/null
+++ b/chromecast/media/cma/backend/alsa/slew_volume.h
@@ -0,0 +1,45 @@
+// 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_INTERNAL_CHIRP_WAVES_SLEW_VOLUME_H_
kmackay 2016/09/14 20:48:15 Change header guard to reflect new location
jyw 2016/09/15 01:12:15 Done.
+#define CHROMECAST_INTERNAL_CHIRP_WAVES_SLEW_VOLUME_H_
+
+#include <stdint.h>
+
+#include "base/macros.h"
kmackay 2016/09/14 20:48:15 not actually used? Need DISALLOW_COPY_AND_ASSIGN?
jyw 2016/09/15 01:12:15 Done.
+
+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
+ bool ProcessFMAC(const float* src, int frames, float* dest);
+
+ // Assumes 2 channels.
+ bool ProcessInterleaved(int32_t* data, int frames);
+
+ private:
+ double volume_scale_ = .1;
kmackay 2016/09/14 20:48:15 why 0.1 here? seems like both should be set to 1.0
jyw 2016/09/15 01:12:15 Done.
+ double current_volume_ = .1;
+ int max_slew_time_up_ms_;
+ int max_slew_time_down_ms_;
+ double max_slew_up_;
+ double max_slew_down_;
+};
+
+} // namespace media
+} // namespace chromecast
+
+#endif // CHROMECAST_INTERNAL_CHIRP_WAVES_SLEW_VOLUME_H_

Powered by Google App Engine
This is Rietveld 408576698