Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_BASE_AUDIO_BUS_H_ | 5 #ifndef MEDIA_BASE_AUDIO_BUS_H_ |
| 6 #define MEDIA_BASE_AUDIO_BUS_H_ | 6 #define MEDIA_BASE_AUDIO_BUS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 | 85 |
| 86 int channels() const { return static_cast<int>(channel_data_.size()); } | 86 int channels() const { return static_cast<int>(channel_data_.size()); } |
| 87 int frames() const { return frames_; } | 87 int frames() const { return frames_; } |
| 88 void set_frames(int frames); | 88 void set_frames(int frames); |
| 89 | 89 |
| 90 // Helper method for zeroing out all channels of audio data. | 90 // Helper method for zeroing out all channels of audio data. |
| 91 void Zero(); | 91 void Zero(); |
| 92 void ZeroFrames(int frames); | 92 void ZeroFrames(int frames); |
| 93 void ZeroFramesPartial(int start_frame, int frames); | 93 void ZeroFramesPartial(int start_frame, int frames); |
| 94 | 94 |
| 95 // Scale internal channel values by 0 <= |volume| <= 1. If an invalid value | |
|
Chris Rogers
2013/04/05 21:31:35
please see comment in .cc about supporting other r
DaleCurtis
2013/04/05 23:52:30
Done.
| |
| 96 // is provided, no adjustment is done. | |
| 97 void AdjustVolume(float volume); | |
| 98 | |
| 95 private: | 99 private: |
| 96 friend struct base::DefaultDeleter<AudioBus>; | 100 friend struct base::DefaultDeleter<AudioBus>; |
| 97 ~AudioBus(); | 101 ~AudioBus(); |
| 98 | 102 |
| 99 AudioBus(int channels, int frames); | 103 AudioBus(int channels, int frames); |
| 100 AudioBus(int channels, int frames, float* data); | 104 AudioBus(int channels, int frames, float* data); |
| 101 AudioBus(int frames, const std::vector<float*>& channel_data); | 105 AudioBus(int frames, const std::vector<float*>& channel_data); |
| 102 explicit AudioBus(int channels); | 106 explicit AudioBus(int channels); |
| 103 | 107 |
| 104 // Helper method for building |channel_data_| from a block of memory. |data| | 108 // Helper method for building |channel_data_| from a block of memory. |data| |
| 105 // must be at least BlockSize() bytes in size. | 109 // must be at least BlockSize() bytes in size. |
| 106 void BuildChannelData(int channels, int aligned_frame, float* data); | 110 void BuildChannelData(int channels, int aligned_frame, float* data); |
| 107 | 111 |
| 108 // Contiguous block of channel memory. | 112 // Contiguous block of channel memory. |
| 109 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; | 113 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; |
| 110 | 114 |
| 111 std::vector<float*> channel_data_; | 115 std::vector<float*> channel_data_; |
| 112 int frames_; | 116 int frames_; |
| 113 | 117 |
| 114 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). | 118 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). |
| 115 bool can_set_channel_data_; | 119 bool can_set_channel_data_; |
| 116 | 120 |
| 117 DISALLOW_COPY_AND_ASSIGN(AudioBus); | 121 DISALLOW_COPY_AND_ASSIGN(AudioBus); |
| 118 }; | 122 }; |
| 119 | 123 |
| 120 } // namespace media | 124 } // namespace media |
| 121 | 125 |
| 122 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 126 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
| OLD | NEW |