#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/audio/simple_sources.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <numbers>
#include <string_view>
#include "base/files/file.h"
#include "base/logging.h"
#include "base/thread_annotations.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/audio/wav_audio_handler.h"
#include "media/base/audio_bus.h"
namespace media {
namespace {
std::unique_ptr<char[]> ReadWavFile(const base::FilePath& wav_filename,
size_t* read_length) { … }
static const int kBeepDurationMilliseconds = …;
static const int kBeepFrequency = …;
static const int kAutomaticBeepIntervalInMs = …;
class BeepContext { … };
BeepContext* GetBeepContext() { … }
}
SineWaveAudioSource::SineWaveAudioSource(int channels,
double freq,
double sample_freq)
: … { … }
SineWaveAudioSource::~SineWaveAudioSource() = default;
int SineWaveAudioSource::OnMoreData(base::TimeDelta ,
base::TimeTicks ,
const AudioGlitchInfo& ,
AudioBus* dest) { … }
void SineWaveAudioSource::OnError(ErrorType type) { … }
void SineWaveAudioSource::CapSamples(int cap) { … }
void SineWaveAudioSource::Reset() { … }
FileSource::FileSource(const AudioParameters& params,
const base::FilePath& path_to_wav_file,
bool loop)
: … { … }
FileSource::~FileSource() = default;
void FileSource::LoadWavFile(const base::FilePath& path_to_wav_file) { … }
int FileSource::OnMoreData(base::TimeDelta ,
base::TimeTicks ,
const AudioGlitchInfo& ,
AudioBus* dest) { … }
void FileSource::Rewind() { … }
double FileSource::ProvideInput(AudioBus* audio_bus_into_converter,
uint32_t frames_delayed,
const AudioGlitchInfo&) { … }
void FileSource::OnError(ErrorType type) { … }
BeepingSource::BeepingSource(const AudioParameters& params)
: … { … }
BeepingSource::~BeepingSource() = default;
int BeepingSource::OnMoreData(base::TimeDelta ,
base::TimeTicks ,
const AudioGlitchInfo& ,
AudioBus* dest) { … }
void BeepingSource::OnError(ErrorType type) { … }
void BeepingSource::BeepOnce() { … }
}