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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/aligned_memory.h" | 14 #include "base/memory/aligned_memory.h" |
15 #include "base/memory/ref_counted.h" | |
16 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 class AudioParameters; | 18 class AudioParameters; |
20 | 19 |
21 // Represents a sequence of audio frames containing frames() audio samples for | 20 // Represents a sequence of audio frames containing frames() audio samples for |
22 // each of channels() channels. The data is stored as a set of contiguous | 21 // each of channels() channels. The data is stored as a set of contiguous |
23 // float arrays with one array per channel. The memory for the arrays is either | 22 // float arrays with one array per channel. The memory for the arrays is either |
24 // allocated and owned by the AudioBus or it is provided to one of the factory | 23 // allocated and owned by the AudioBus or it is provided to one of the factory |
25 // methods. AudioBus guarantees that it allocates memory such that float array | 24 // methods. AudioBus guarantees that it allocates memory such that float array |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 for (int source_frame_index = read_offset_in_frames, write_pos_in_dest = ch; | 298 for (int source_frame_index = read_offset_in_frames, write_pos_in_dest = ch; |
300 source_frame_index < read_offset_in_frames + num_frames_to_read; | 299 source_frame_index < read_offset_in_frames + num_frames_to_read; |
301 ++source_frame_index, write_pos_in_dest += channels) { | 300 ++source_frame_index, write_pos_in_dest += channels) { |
302 float sourceSampleValue = channel_data[source_frame_index]; | 301 float sourceSampleValue = channel_data[source_frame_index]; |
303 dest_buffer[write_pos_in_dest] = | 302 dest_buffer[write_pos_in_dest] = |
304 TargetSampleTypeTraits::FromFloat(sourceSampleValue); | 303 TargetSampleTypeTraits::FromFloat(sourceSampleValue); |
305 } | 304 } |
306 } | 305 } |
307 } | 306 } |
308 | 307 |
309 // RefCounted version of AudioBus. This is not meant for general use. Only use | |
310 // this when your lifetime requirements make it impossible to use an | |
311 // AudioBus scoped_ptr. | |
312 class MEDIA_EXPORT AudioBusRefCounted | |
313 : public media::AudioBus, | |
314 public base::RefCountedThreadSafe<AudioBusRefCounted> { | |
315 public: | |
316 static scoped_refptr<AudioBusRefCounted> Create(int channels, int frames); | |
317 | |
318 private: | |
319 friend class base::RefCountedThreadSafe<AudioBusRefCounted>; | |
320 | |
321 AudioBusRefCounted(int channels, int frames); | |
322 ~AudioBusRefCounted() override; | |
323 | |
324 DISALLOW_COPY_AND_ASSIGN(AudioBusRefCounted); | |
325 }; | |
326 | |
327 } // namespace media | 308 } // namespace media |
328 | 309 |
329 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 310 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
OLD | NEW |