| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // allocated and owned by the AudioBus or it is provided to one of the factory | 24 // allocated and owned by the AudioBus or it is provided to one of the factory |
| 25 // methods. AudioBus guarantees that it allocates memory such that float array | 25 // methods. AudioBus guarantees that it allocates memory such that float array |
| 26 // for each channel is aligned by AudioBus::kChannelAlignment bytes and it | 26 // for each channel is aligned by AudioBus::kChannelAlignment bytes and it |
| 27 // requires the same for memory passed to its Wrap...() factory methods. | 27 // requires the same for memory passed to its Wrap...() factory methods. |
| 28 // TODO(chfremer): There are currently no unit tests involving CreateWrapper and | 28 // TODO(chfremer): There are currently no unit tests involving CreateWrapper and |
| 29 // SetChannelData, so we need to add them. | 29 // SetChannelData, so we need to add them. |
| 30 class MEDIA_EXPORT AudioBus { | 30 class MEDIA_EXPORT AudioBus { |
| 31 public: | 31 public: |
| 32 // Guaranteed alignment of each channel's data; use 16-byte alignment for easy | 32 // Guaranteed alignment of each channel's data; use 16-byte alignment for easy |
| 33 // SSE optimizations. | 33 // SSE optimizations. |
| 34 enum { kChannelAlignment = 16 }; | 34 enum { kChannelAlignment = 32 }; |
| 35 | 35 |
| 36 // Creates a new AudioBus and allocates |channels| of length |frames|. Uses | 36 // Creates a new AudioBus and allocates |channels| of length |frames|. Uses |
| 37 // channels() and frames_per_buffer() from AudioParameters if given. | 37 // channels() and frames_per_buffer() from AudioParameters if given. |
| 38 static std::unique_ptr<AudioBus> Create(int channels, int frames); | 38 static std::unique_ptr<AudioBus> Create(int channels, int frames); |
| 39 static std::unique_ptr<AudioBus> Create(const AudioParameters& params); | 39 static std::unique_ptr<AudioBus> Create(const AudioParameters& params); |
| 40 | 40 |
| 41 // Creates a new AudioBus with the given number of channels, but zero length. | 41 // Creates a new AudioBus with the given number of channels, but zero length. |
| 42 // Clients are expected to subsequently call SetChannelData() and set_frames() | 42 // Clients are expected to subsequently call SetChannelData() and set_frames() |
| 43 // to wrap externally allocated memory. | 43 // to wrap externally allocated memory. |
| 44 static std::unique_ptr<AudioBus> CreateWrapper(int channels); | 44 static std::unique_ptr<AudioBus> CreateWrapper(int channels); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 AudioBusRefCounted(int channels, int frames); | 321 AudioBusRefCounted(int channels, int frames); |
| 322 ~AudioBusRefCounted() override; | 322 ~AudioBusRefCounted() override; |
| 323 | 323 |
| 324 DISALLOW_COPY_AND_ASSIGN(AudioBusRefCounted); | 324 DISALLOW_COPY_AND_ASSIGN(AudioBusRefCounted); |
| 325 }; | 325 }; |
| 326 | 326 |
| 327 } // namespace media | 327 } // namespace media |
| 328 | 328 |
| 329 #endif // MEDIA_BASE_AUDIO_BUS_H_ | 329 #endif // MEDIA_BASE_AUDIO_BUS_H_ |
| OLD | NEW |