chromium/media/audio/audio_input_device.cc

// 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/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 {

// The number of shared memory buffer segments indicated to browser process
// in order to avoid data overwriting. This number can be any positive number,
// dependent how fast the renderer process can pick up captured data from
// shared memory.
const int kRequestedSharedMemoryCount =;

// The number of seconds with missing callbacks before we report a capture
// error. The value is based on that the Mac audio implementation can defer
// start for 5 seconds when resuming after standby, and has a startup success
// check 5 seconds after actually starting, where stats is logged. We must allow
// enough time for this. See AUAudioInputStream::CheckInputStartupSuccess().
const int kMissingCallbacksTimeBeforeErrorSeconds =;

// The interval for checking missing callbacks.
const int kCheckMissingCallbacksIntervalSeconds =;

// How often AudioInputDevice::AudioThreadCallback informs that it has gotten
// data from the source.
const int kGotDataCallbackIntervalSeconds =;

base::ThreadType ThreadTypeFromPurpose(AudioInputDevice::Purpose purpose) {}

}  // namespace

// Takes care of invoking the capture callback on the audio thread.
// An instance of this class is created for each capture stream in
// OnLowLatencyCreated().
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
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() {}

}  // namespace media