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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 // Uses channels() and frames_per_buffer() from AudioParameters if given. | 65 // Uses channels() and frames_per_buffer() from AudioParameters if given. |
66 static int CalculateMemorySize(int channels, int frames); | 66 static int CalculateMemorySize(int channels, int frames); |
67 static int CalculateMemorySize(const AudioParameters& params); | 67 static int CalculateMemorySize(const AudioParameters& params); |
68 | 68 |
69 // Methods that are expected to be called after AudioBus::CreateWrapper() in | 69 // Methods that are expected to be called after AudioBus::CreateWrapper() in |
70 // order to wrap externally allocated memory. Note: It is illegal to call | 70 // order to wrap externally allocated memory. Note: It is illegal to call |
71 // these methods when using a factory method other than CreateWrapper(). | 71 // these methods when using a factory method other than CreateWrapper(). |
72 void SetChannelData(int channel, float* data); | 72 void SetChannelData(int channel, float* data); |
73 void set_frames(int frames); | 73 void set_frames(int frames); |
74 | 74 |
75 int data_size() const { return data_size_; } | |
76 void set_data_size(int data_size); | |
DaleCurtis
2016/11/01 23:05:13
hacker_style() methods must be inline; I know we h
AndyWu
2016/11/04 18:04:24
Thanks, I fixed hacker_style() methods.
Last time
| |
77 | |
78 int is_raw_format() const { return is_raw_format_; } | |
79 void set_is_raw_format(bool is_raw_format); | |
80 | |
75 // Overwrites the sample values stored in this AudioBus instance with values | 81 // Overwrites the sample values stored in this AudioBus instance with values |
76 // from a given interleaved |source_buffer| with expected layout | 82 // from a given interleaved |source_buffer| with expected layout |
77 // [ch0, ch1, ..., chN, ch0, ch1, ...] and sample values in the format | 83 // [ch0, ch1, ..., chN, ch0, ch1, ...] and sample values in the format |
78 // corresponding to the given SourceSampleTypeTraits. | 84 // corresponding to the given SourceSampleTypeTraits. |
79 // The sample values are converted to float values by means of the method | 85 // The sample values are converted to float values by means of the method |
80 // convert_to_float32() provided by the SourceSampleTypeTraits. For a list of | 86 // convert_to_float32() provided by the SourceSampleTypeTraits. For a list of |
81 // ready-to-use SampleTypeTraits, see file audio_sample_types.h. | 87 // ready-to-use SampleTypeTraits, see file audio_sample_types.h. |
82 // If |num_frames_to_write| is less than frames(), the remaining frames are | 88 // If |num_frames_to_write| is less than frames(), the remaining frames are |
83 // zeroed out. If |num_frames_to_write| is more than frames(), this results in | 89 // zeroed out. If |num_frames_to_write| is more than frames(), this results in |
84 // undefined behavior. | 90 // undefined behavior. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 | 208 |
203 template <class TargetSampleTypeTraits> | 209 template <class TargetSampleTypeTraits> |
204 static void CopyConvertFromAudioBusToInterleavedTarget( | 210 static void CopyConvertFromAudioBusToInterleavedTarget( |
205 const AudioBus* source, | 211 const AudioBus* source, |
206 int read_offset_in_frames, | 212 int read_offset_in_frames, |
207 int num_frames_to_read, | 213 int num_frames_to_read, |
208 typename TargetSampleTypeTraits::ValueType* dest_buffer); | 214 typename TargetSampleTypeTraits::ValueType* dest_buffer); |
209 | 215 |
210 // Contiguous block of channel memory. | 216 // Contiguous block of channel memory. |
211 std::unique_ptr<float, base::AlignedFreeDeleter> data_; | 217 std::unique_ptr<float, base::AlignedFreeDeleter> data_; |
218 int data_size_; | |
219 bool is_raw_format_; | |
212 | 220 |
213 // One float pointer per channel pointing to a contiguous block of memory for | 221 // One float pointer per channel pointing to a contiguous block of memory for |
214 // that channel. If the memory is owned by this instance, this will | 222 // that channel. If the memory is owned by this instance, this will |
215 // point to the memory in |data_|. Otherwise, it may point to memory provided | 223 // point to the memory in |data_|. Otherwise, it may point to memory provided |
216 // by the client. | 224 // by the client. |
217 std::vector<float*> channel_data_; | 225 std::vector<float*> channel_data_; |
218 int frames_; | 226 int frames_; |
219 | 227 |
220 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). | 228 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). |
221 bool can_set_channel_data_; | 229 bool can_set_channel_data_; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 | 328 |
321 AudioBusRefCounted(int channels, int frames); | 329 AudioBusRefCounted(int channels, int frames); |
322 ~AudioBusRefCounted() override; | 330 ~AudioBusRefCounted() override; |
323 | 331 |
324 DISALLOW_COPY_AND_ASSIGN(AudioBusRefCounted); | 332 DISALLOW_COPY_AND_ASSIGN(AudioBusRefCounted); |
325 }; | 333 }; |
326 | 334 |
327 } // namespace media | 335 } // namespace media |
328 | 336 |
329 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 337 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
OLD | NEW |