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

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

Issue 2341783004: [chromecast] Slew stream volume changes in StreamMixerAlsa. (Closed)
Patch Set: Slew stream volume changes in StreamMixerAlsa. 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..438502a3acf8f33de443fc6f7646ee7aa7f5b4c7
--- /dev/null
+++ b/chromecast/media/cma/backend/alsa/slew_volume.h
@@ -0,0 +1,53 @@
+// 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 that is 16-byte aligned. Smoothly calculates
+ // dest[i] += src[i] * volume_scaling
+ // ProcessFMAC will be called once for each channel of audio present and
+ // |repeat_transition| will be true for channels 2 through n.
+ void ProcessFMAC(bool repeat_transition,
+ 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;
+ double last_starting_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