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 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 // Creates a new AudioBus by wrapping an existing block of memory. Block must | 39 // Creates a new AudioBus by wrapping an existing block of memory. Block must |
40 // be at least CalculateMemorySize() bytes in size. |data| must outlive the | 40 // be at least CalculateMemorySize() bytes in size. |data| must outlive the |
41 // returned AudioBus. |data| must be aligned by kChannelAlignment. | 41 // returned AudioBus. |data| must be aligned by kChannelAlignment. |
42 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data); | 42 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data); |
43 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params, | 43 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params, |
44 void* data); | 44 void* data); |
45 // Returns the required memory size to use the WrapMemory() method. | 45 // Returns the required memory size to use the WrapMemory() method. |
46 static int CalculateMemorySize(const AudioParameters& params); | 46 static int CalculateMemorySize(const AudioParameters& params); |
47 | 47 |
48 // Calculates the required size for an AudioBus given the number of channels | |
henrika (OOO until Aug 14)
2012/09/11 21:44:48
Why is this comment different from the comment abo
| |
49 // and frames. | |
50 static int CalculateMemorySize(int channels, int frames); | |
51 | |
48 // Helper methods for converting an AudioBus from and to interleaved integer | 52 // Helper methods for converting an AudioBus from and to interleaved integer |
49 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with | 53 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with |
50 // |bytes_per_sample| per value. Values are scaled and bias corrected during | 54 // |bytes_per_sample| per value. Values are scaled and bias corrected during |
51 // conversion. ToInterleaved() will also clip values to format range. | 55 // conversion. ToInterleaved() will also clip values to format range. |
52 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out | 56 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out |
53 // any unfilled frames when |frames| is less than frames(). | 57 // any unfilled frames when |frames| is less than frames(). |
54 void FromInterleaved(const void* source, int frames, int bytes_per_sample); | 58 void FromInterleaved(const void* source, int frames, int bytes_per_sample); |
55 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const; | 59 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const; |
56 | 60 |
57 // Similar to FromInterleaved() above, but meant for streaming sources. Does | 61 // Similar to FromInterleaved() above, but meant for streaming sources. Does |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 100 |
97 std::vector<float*> channel_data_; | 101 std::vector<float*> channel_data_; |
98 int frames_; | 102 int frames_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(AudioBus); | 104 DISALLOW_COPY_AND_ASSIGN(AudioBus); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace media | 107 } // namespace media |
104 | 108 |
105 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 109 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
OLD | NEW |