| 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 29 matching lines...) Expand all Loading... |
| 40 // the returned AudioBus. Each channel must be aligned by kChannelAlignment. | 40 // the returned AudioBus. Each channel must be aligned by kChannelAlignment. |
| 41 static scoped_ptr<AudioBus> WrapVector( | 41 static scoped_ptr<AudioBus> WrapVector( |
| 42 int frames, const std::vector<float*>& channel_data); | 42 int frames, const std::vector<float*>& channel_data); |
| 43 | 43 |
| 44 // Creates a new AudioBus by wrapping an existing block of memory. Block must | 44 // Creates a new AudioBus by wrapping an existing block of memory. Block must |
| 45 // be at least CalculateMemorySize() bytes in size. |data| must outlive the | 45 // be at least CalculateMemorySize() bytes in size. |data| must outlive the |
| 46 // returned AudioBus. |data| must be aligned by kChannelAlignment. | 46 // returned AudioBus. |data| must be aligned by kChannelAlignment. |
| 47 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data); | 47 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data); |
| 48 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params, | 48 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params, |
| 49 void* data); | 49 void* data); |
| 50 // Returns the required memory size to use the WrapMemory() method. | |
| 51 static int CalculateMemorySize(const AudioParameters& params); | 50 static int CalculateMemorySize(const AudioParameters& params); |
| 52 | 51 |
| 53 // Calculates the required size for an AudioBus given the number of channels | 52 // Calculates the required size for an AudioBus given the number of channels |
| 54 // and frames. | 53 // and frames. |
| 55 static int CalculateMemorySize(int channels, int frames); | 54 static int CalculateMemorySize(int channels, int frames); |
| 56 | 55 |
| 57 // Helper methods for converting an AudioBus from and to interleaved integer | 56 // Helper methods for converting an AudioBus from and to interleaved integer |
| 58 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with | 57 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with |
| 59 // |bytes_per_sample| per value. Values are scaled and bias corrected during | 58 // |bytes_per_sample| per value. Values are scaled and bias corrected during |
| 60 // conversion. ToInterleaved() will also clip values to format range. | 59 // conversion. ToInterleaved() will also clip values to format range. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 125 |
| 127 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). | 126 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). |
| 128 bool can_set_channel_data_; | 127 bool can_set_channel_data_; |
| 129 | 128 |
| 130 DISALLOW_COPY_AND_ASSIGN(AudioBus); | 129 DISALLOW_COPY_AND_ASSIGN(AudioBus); |
| 131 }; | 130 }; |
| 132 | 131 |
| 133 } // namespace media | 132 } // namespace media |
| 134 | 133 |
| 135 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 134 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
| OLD | NEW |