| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Scale volume with slew rate limiting | 5 // Scale volume with slew rate limiting |
| 6 | 6 |
| 7 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ | 7 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |
| 8 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ | 8 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Assumes 1 channel float data that is 16-byte aligned. Smoothly calculates | 31 // Assumes 1 channel float data that is 16-byte aligned. Smoothly calculates |
| 32 // dest[i] += src[i] * volume_scaling | 32 // dest[i] += src[i] * volume_scaling |
| 33 // ProcessFMAC will be called once for each channel of audio present and | 33 // ProcessFMAC will be called once for each channel of audio present and |
| 34 // |repeat_transition| will be true for channels 2 through n. | 34 // |repeat_transition| will be true for channels 2 through n. |
| 35 void ProcessFMAC(bool repeat_transition, | 35 void ProcessFMAC(bool repeat_transition, |
| 36 const float* src, | 36 const float* src, |
| 37 int frames, | 37 int frames, |
| 38 float* dest); | 38 float* dest); |
| 39 | 39 |
| 40 // Processes a single channel of float data |
| 41 // dest[i] = src[i] * volume_scaling. |
| 42 // ProcessFMUL will be called once for each channel of audio present. |
| 43 // |repeat_transition| should be true for channels 2 through n. |
| 40 // Assumes 2 channels. | 44 // Assumes 2 channels. |
| 41 bool ProcessInterleaved(int32_t* data, int frames); | 45 void ProcessFMUL(bool repeat_transition, |
| 46 const float* src, |
| 47 int frames, |
| 48 float* dest); |
| 42 | 49 |
| 43 private: | 50 private: |
| 51 template <typename Traits> |
| 52 void ProcessData(bool repeat_transition, |
| 53 const float* src, |
| 54 int frames, |
| 55 float* dest); |
| 56 |
| 44 double sample_rate_; | 57 double sample_rate_; |
| 45 double volume_scale_ = 1.0; | 58 double volume_scale_ = 1.0; |
| 46 double current_volume_ = 1.0; | 59 double current_volume_ = 1.0; |
| 47 double last_starting_volume_ = 1.0; | 60 double last_starting_volume_ = 1.0; |
| 48 double max_slew_time_ms_; | 61 double max_slew_time_ms_; |
| 49 double max_slew_per_sample_; | 62 double max_slew_per_sample_; |
| 50 bool interrupted_ = true; | 63 bool interrupted_ = true; |
| 51 | 64 |
| 52 DISALLOW_COPY_AND_ASSIGN(SlewVolume); | 65 DISALLOW_COPY_AND_ASSIGN(SlewVolume); |
| 53 }; | 66 }; |
| 54 | 67 |
| 55 } // namespace media | 68 } // namespace media |
| 56 } // namespace chromecast | 69 } // namespace chromecast |
| 57 | 70 |
| 58 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ | 71 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_SLEW_VOLUME_H_ |
| OLD | NEW |