// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/40285824): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "media/base/audio_fifo.h" #include <cstring> #include "base/check_op.h" #include "base/trace_event/trace_event.h" namespace media { // Given current position in the FIFO, the maximum number of elements in the // FIFO and the size of the input; this method provides two output results: // |size| and |wrap_size|. These two results can then be utilized for memcopy // operations to and from the FIFO. // Under "normal" circumstances, |size| will be equal to |in_size| and // |wrap_size| will be zero. This case corresponding to the non-wrapping case // where we have not yet reached the "edge" of the FIFO. If |pos| + |in_size| // exceeds the total size of the FIFO, we must wrap around and start reusing // a part the allocated memory. The size of this part is given by |wrap_size|. static void GetSizes( int pos, int max_size, int in_size, int* size, int* wrap_size) { … } // Updates the read/write position with |step| modulo the maximum number of // elements in the FIFO to ensure that the position counters wraps around at // the endpoint. static int UpdatePos(int pos, int step, int max_size) { … } AudioFifo::AudioFifo(int channels, int frames) : … { … } AudioFifo::~AudioFifo() = default; void AudioFifo::Push(const AudioBus* source) { … } void AudioFifo::Push(const AudioBus* source, int source_size) { … } void AudioFifo::Consume(AudioBus* destination, int start_frame, int frames_to_consume) { … } void AudioFifo::Clear() { … } } // namespace media