Index: media/base/audio_bus.cc |
=================================================================== |
--- media/base/audio_bus.cc (revision 155437) |
+++ media/base/audio_bus.cc (working copy) |
@@ -17,19 +17,6 @@ |
(AudioBus::kChannelAlignment - 1)) == 0U; |
} |
-// Calculates the required size for an AudioBus with the given params, sets |
-// |aligned_frames| to the actual frame length of each channel array. |
-static int CalculateMemorySizeInternal(int channels, int frames, |
- int* aligned_frames) { |
- CHECK(aligned_frames); |
- // Choose a size such that each channel will be aligned by kChannelAlignment |
- // when stored in a contiguous block. |
- *aligned_frames = |
- ((frames * sizeof(float) + AudioBus::kChannelAlignment - 1) & |
- ~(AudioBus::kChannelAlignment - 1)) / sizeof(float); |
- return sizeof(float) * channels * (*aligned_frames); |
-} |
- |
// |Format| is the destination type, |Fixed| is a type larger than |Format| |
// such that operations can be made without overflowing. |
template<class Format, class Fixed> |
@@ -106,7 +93,7 @@ |
ValidateConfig(channels, frames_); |
int aligned_frames = 0; |
- int size = CalculateMemorySizeInternal(channels, frames, &aligned_frames); |
+ int size = CalculateMemorySizeFromChannels(channels, frames, &aligned_frames); |
data_.reset(static_cast<float*>(base::AlignedAlloc( |
size, AudioBus::kChannelAlignment))); |
@@ -119,7 +106,7 @@ |
ValidateConfig(channels, frames_); |
int aligned_frames = 0; |
- CalculateMemorySizeInternal(channels, frames, &aligned_frames); |
+ CalculateMemorySizeFromChannels(channels, frames, &aligned_frames); |
BuildChannelData(channels, aligned_frames, data); |
} |
@@ -187,9 +174,25 @@ |
ZeroFrames(frames_); |
} |
+// Calculates the required size for an AudioBus with the given params, sets |
+// |aligned_frames| to the actual frame length of each channel array. |
+int AudioBus::CalculateMemorySizeFromChannels(int channels, int frames, |
+ int* out_aligned_frames) { |
+ // Choose a size such that each channel will be aligned by |
+ // kChannelAlignment when stored in a contiguous block. |
+ int aligned_frames = |
+ ((frames * sizeof(float) + AudioBus::kChannelAlignment - 1) & |
+ ~(AudioBus::kChannelAlignment - 1)) / sizeof(float); |
+ |
+ if (out_aligned_frames) |
+ *out_aligned_frames = aligned_frames; |
+ |
+ return sizeof(float) * channels * aligned_frames; |
+} |
+ |
int AudioBus::CalculateMemorySize(const AudioParameters& params) { |
int aligned_frames = 0; |
- return CalculateMemorySizeInternal( |
+ return CalculateMemorySizeFromChannels( |
params.channels(), params.frames_per_buffer(), &aligned_frames); |
} |