Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1252)

Side by Side Diff: media/base/audio_bus.h

Issue 2845813004: Add unit test for AudioBus::CreateWrapper() (Closed)
Patch Set: Add unit test for AudioBus::CreateWrapper() Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 16
17 namespace media { 17 namespace media {
18 class AudioParameters; 18 class AudioParameters;
19 19
20 // Represents a sequence of audio frames containing frames() audio samples for 20 // Represents a sequence of audio frames containing frames() audio samples for
21 // 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
22 // 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
23 // 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
24 // methods. AudioBus guarantees that it allocates memory such that float array 24 // methods. AudioBus guarantees that it allocates memory such that float array
25 // for each channel is aligned by AudioBus::kChannelAlignment bytes and it 25 // for each channel is aligned by AudioBus::kChannelAlignment bytes and it
26 // requires the same for memory passed to its Wrap...() factory methods. 26 // requires the same for memory passed to its Wrap...() factory methods.
27 // TODO(chfremer): There are currently no unit tests involving CreateWrapper and
28 // SetChannelData, so we need to add them.
29 class MEDIA_EXPORT AudioBus { 27 class MEDIA_EXPORT AudioBus {
30 public: 28 public:
31 // Guaranteed alignment of each channel's data; use 16-byte alignment for easy 29 // Guaranteed alignment of each channel's data; use 16-byte alignment for easy
32 // SSE optimizations. 30 // SSE optimizations.
33 enum { kChannelAlignment = 16 }; 31 enum { kChannelAlignment = 16 };
34 32
35 // Creates a new AudioBus and allocates |channels| of length |frames|. Uses 33 // Creates a new AudioBus and allocates |channels| of length |frames|. Uses
36 // channels() and frames_per_buffer() from AudioParameters if given. 34 // channels() and frames_per_buffer() from AudioParameters if given.
37 static std::unique_ptr<AudioBus> Create(int channels, int frames); 35 static std::unique_ptr<AudioBus> Create(int channels, int frames);
38 static std::unique_ptr<AudioBus> Create(const AudioParameters& params); 36 static std::unique_ptr<AudioBus> Create(const AudioParameters& params);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 float sourceSampleValue = channel_data[source_frame_index]; 299 float sourceSampleValue = channel_data[source_frame_index];
302 dest_buffer[write_pos_in_dest] = 300 dest_buffer[write_pos_in_dest] =
303 TargetSampleTypeTraits::FromFloat(sourceSampleValue); 301 TargetSampleTypeTraits::FromFloat(sourceSampleValue);
304 } 302 }
305 } 303 }
306 } 304 }
307 305
308 } // namespace media 306 } // namespace media
309 307
310 #endif // MEDIA_BASE_AUDIO_BUS_H_ 308 #endif // MEDIA_BASE_AUDIO_BUS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698