// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_BASE_AUDIO_BUFFER_H_ #define MEDIA_BASE_AUDIO_BUFFER_H_ #include <stddef.h> #include <stdint.h> #include <list> #include <memory> #include <utility> #include <vector> #include "base/containers/span.h" #include "base/memory/aligned_memory.h" #include "base/memory/raw_span.h" #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" #include "base/thread_annotations.h" #include "base/time/time.h" #include "media/base/audio_bus.h" #include "media/base/channel_layout.h" #include "media/base/media_export.h" #include "media/base/sample_format.h" namespace mojo { template <typename T, typename U> struct TypeConverter; template <typename T> class StructPtr; } // namespace mojo namespace media { class AudioBufferMemoryPool; namespace mojom { class AudioBuffer; } // An audio buffer that takes a copy of the data passed to it, holds it, and // copies it into an AudioBus when needed. Also supports an end of stream // marker. class MEDIA_EXPORT AudioBuffer : public base::RefCountedThreadSafe<AudioBuffer> { … }; // Basic memory pool for reusing AudioBuffer internal memory to avoid thrashing. // // The pool is managed in a last-in-first-out manner, returned buffers are put // at the back of the queue. When a new buffer is requested by AudioBuffer, we // will scan from the front to find a matching buffer. All non-matching buffers // are dropped. The assumption is that when we reach steady-state all buffers // will have the same sized allocation. At most the pool will be equal in size // to the maximum number of concurrent AudioBuffer instances. // // Each AudioBuffer instance created with an AudioBufferMemoryPool will take a // ref on the pool instance so that it may return buffers in the future. class MEDIA_EXPORT AudioBufferMemoryPool : public base::RefCountedThreadSafe<AudioBufferMemoryPool> { … }; } // namespace media #endif // MEDIA_BASE_AUDIO_BUFFER_H_