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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 int channels() const { return channel_data_.size(); } | 84 int channels() const { return channel_data_.size(); } |
85 int frames() const { return frames_; } | 85 int frames() const { return frames_; } |
86 void set_frames(int frames); | 86 void set_frames(int frames); |
87 | 87 |
88 // Helper method for zeroing out all channels of audio data. | 88 // Helper method for zeroing out all channels of audio data. |
89 void Zero(); | 89 void Zero(); |
90 void ZeroFrames(int frames); | 90 void ZeroFrames(int frames); |
91 void ZeroFramesPartial(int start_frame, int frames); | 91 void ZeroFramesPartial(int start_frame, int frames); |
92 | 92 |
93 private: | 93 private: |
94 friend class scoped_ptr<AudioBus>; | 94 friend struct base::DefaultDeleter<AudioBus>; |
95 ~AudioBus(); | 95 ~AudioBus(); |
96 | 96 |
97 AudioBus(int channels, int frames); | 97 AudioBus(int channels, int frames); |
98 AudioBus(int channels, int frames, float* data); | 98 AudioBus(int channels, int frames, float* data); |
99 AudioBus(int frames, const std::vector<float*>& channel_data); | 99 AudioBus(int frames, const std::vector<float*>& channel_data); |
100 explicit AudioBus(int channels); | 100 explicit AudioBus(int channels); |
101 | 101 |
102 // Helper method for building |channel_data_| from a block of memory. |data| | 102 // Helper method for building |channel_data_| from a block of memory. |data| |
103 // must be at least BlockSize() bytes in size. | 103 // must be at least BlockSize() bytes in size. |
104 void BuildChannelData(int channels, int aligned_frame, float* data); | 104 void BuildChannelData(int channels, int aligned_frame, float* data); |
105 | 105 |
106 // Contiguous block of channel memory. | 106 // Contiguous block of channel memory. |
107 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; | 107 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; |
108 | 108 |
109 std::vector<float*> channel_data_; | 109 std::vector<float*> channel_data_; |
110 int frames_; | 110 int frames_; |
111 | 111 |
112 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). | 112 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). |
113 bool can_set_channel_data_; | 113 bool can_set_channel_data_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(AudioBus); | 115 DISALLOW_COPY_AND_ASSIGN(AudioBus); |
116 }; | 116 }; |
117 | 117 |
118 } // namespace media | 118 } // namespace media |
119 | 119 |
120 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 120 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
OLD | NEW |