| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 static int CalculateMemorySize(int channels, int frames); | 55 static int CalculateMemorySize(int channels, int frames); |
| 56 | 56 |
| 57 // Helper methods for converting an AudioBus from and to interleaved integer | 57 // Helper methods for converting an AudioBus from and to interleaved integer |
| 58 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with | 58 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with |
| 59 // |bytes_per_sample| per value. Values are scaled and bias corrected during | 59 // |bytes_per_sample| per value. Values are scaled and bias corrected during |
| 60 // conversion. ToInterleaved() will also clip values to format range. | 60 // conversion. ToInterleaved() will also clip values to format range. |
| 61 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out | 61 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out |
| 62 // any unfilled frames when |frames| is less than frames(). | 62 // any unfilled frames when |frames| is less than frames(). |
| 63 void FromInterleaved(const void* source, int frames, int bytes_per_sample); | 63 void FromInterleaved(const void* source, int frames, int bytes_per_sample); |
| 64 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const; | 64 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const; |
| 65 void ToInterleavedPartial(int start_frame, int frames, int bytes_per_sample, |
| 66 void* dest) const; |
| 65 | 67 |
| 66 // Similar to FromInterleaved() above, but meant for streaming sources. Does | 68 // Similar to FromInterleaved() above, but meant for streaming sources. Does |
| 67 // not zero out remaining frames, the caller is responsible for doing so using | 69 // not zero out remaining frames, the caller is responsible for doing so using |
| 68 // ZeroFramesPartial(). Frames are deinterleaved from the start of |source| | 70 // ZeroFramesPartial(). Frames are deinterleaved from the start of |source| |
| 69 // to channel(x)[start_frame]. | 71 // to channel(x)[start_frame]. |
| 70 void FromInterleavedPartial(const void* source, int start_frame, int frames, | 72 void FromInterleavedPartial(const void* source, int start_frame, int frames, |
| 71 int bytes_per_sample); | 73 int bytes_per_sample); |
| 72 | 74 |
| 73 // Helper method for copying channel data from one AudioBus to another. Both | 75 // Helper method for copying channel data from one AudioBus to another. Both |
| 74 // AudioBus object must have the same frames() and channels(). | 76 // AudioBus object must have the same frames() and channels(). |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 113 |
| 112 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). | 114 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). |
| 113 bool can_set_channel_data_; | 115 bool can_set_channel_data_; |
| 114 | 116 |
| 115 DISALLOW_COPY_AND_ASSIGN(AudioBus); | 117 DISALLOW_COPY_AND_ASSIGN(AudioBus); |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 } // namespace media | 120 } // namespace media |
| 119 | 121 |
| 120 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 122 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
| OLD | NEW |