#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/audio/audio_input_device.h"
#include <stdint.h>
#include <utility>
#include <vector>
#include "audio_device_stats_reporter.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "media/audio/audio_manager_base.h"
#include "media/base/audio_bus.h"
namespace media {
namespace {
const int kRequestedSharedMemoryCount = …;
const int kMissingCallbacksTimeBeforeErrorSeconds = …;
const int kCheckMissingCallbacksIntervalSeconds = …;
const int kGotDataCallbackIntervalSeconds = …;
base::ThreadType ThreadTypeFromPurpose(AudioInputDevice::Purpose purpose) { … }
}
class AudioInputDevice::AudioThreadCallback
: public AudioDeviceThread::Callback { … };
AudioInputDevice::AudioInputDevice(std::unique_ptr<AudioInputIPC> ipc,
Purpose purpose,
DeadStreamDetection detect_dead_stream)
: … { … }
void AudioInputDevice::Initialize(const AudioParameters& params,
CaptureCallback* callback) { … }
void AudioInputDevice::Start() { … }
void AudioInputDevice::Stop() { … }
void AudioInputDevice::SetVolume(double volume) { … }
void AudioInputDevice::SetAutomaticGainControl(bool enabled) { … }
void AudioInputDevice::SetOutputDeviceForAec(
const std::string& output_device_id) { … }
void AudioInputDevice::OnStreamCreated(
base::ReadOnlySharedMemoryRegion shared_memory_region,
base::SyncSocket::ScopedHandle socket_handle,
bool initially_muted) { … }
void AudioInputDevice::OnError(AudioCapturerSource::ErrorCode code) { … }
void AudioInputDevice::OnMuted(bool is_muted) { … }
void AudioInputDevice::OnIPCClosed() { … }
AudioInputDevice::~AudioInputDevice() { … }
void AudioInputDevice::DetectedDeadInputStream() { … }
AudioInputDevice::AudioThreadCallback::AudioThreadCallback(
const AudioParameters& audio_parameters,
base::ReadOnlySharedMemoryRegion shared_memory_region,
uint32_t total_segments,
bool enable_uma,
CaptureCallback* capture_callback,
base::RepeatingClosure got_data_callback_)
: … { … }
AudioInputDevice::AudioThreadCallback::~AudioThreadCallback() { … }
void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { … }
void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { … }
void AudioInputDevice::AudioThreadCallback::OnSocketError() { … }
}