#include "services/audio/output_controller.h"
#include <inttypes.h>
#include <stdio.h>
#include <string>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/media_buildflags.h"
#include "services/audio/device_listener_output_stream.h"
#include "services/audio/stream_monitor.h"
namespace audio {
namespace {
constexpr base::TimeDelta kPowerMonitorLogInterval = …;
const char* StateToString(OutputController::State state) { … }
const char* ErrorTypeToString(
media::AudioOutputStream::AudioSourceCallback::ErrorType type) { … }
}
OutputController::ErrorStatisticsTracker::ErrorStatisticsTracker(
OutputController* controller)
: … { … }
OutputController::ErrorStatisticsTracker::~ErrorStatisticsTracker() { … }
void OutputController::ErrorStatisticsTracker::RegisterError() { … }
void OutputController::ErrorStatisticsTracker::OnMoreDataCalled() { … }
void OutputController::ErrorStatisticsTracker::WedgeCheck() { … }
OutputController::OutputController(
media::AudioManager* audio_manager,
EventHandler* handler,
const media::AudioParameters& params,
const std::string& output_device_id,
SyncReader* sync_reader,
ManagedDeviceOutputStreamCreateCallback
managed_device_output_stream_create_callback)
: … { … }
OutputController::~OutputController() { … }
bool OutputController::CreateStream() { … }
void OutputController::ReportStreamCreationUma(
OutputController::RecreateReason reason,
StreamCreationResult result) { … }
const char* OutputController::RecreateReasonToString(
OutputController::RecreateReason reason) { … }
void OutputController::RecreateStream(OutputController::RecreateReason reason) { … }
void OutputController::Play() { … }
void OutputController::StartStream() { … }
void OutputController::StopStream() { … }
void OutputController::Pause() { … }
void OutputController::Flush() { … }
void OutputController::Close() { … }
void OutputController::SetVolume(double volume) { … }
int OutputController::OnMoreData(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
const media::AudioGlitchInfo& glitch_info,
media::AudioBus* dest) { … }
int OutputController::OnMoreData(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
const media::AudioGlitchInfo& glitch_info,
media::AudioBus* dest,
bool is_mixing) { … }
void OutputController::SendLogMessage(const char* format, ...) { … }
void OutputController::LogAudioPowerLevel(const char* call_name) { … }
void OutputController::OnError(ErrorType type) { … }
void OutputController::StopCloseAndClearStream() { … }
const media::AudioParameters& OutputController::GetAudioParameters() const { … }
void OutputController::StartSnooping(Snooper* snooper) { … }
void OutputController::StopSnooping(Snooper* snooper) { … }
void OutputController::StartMuting() { … }
void OutputController::StopMuting() { … }
void OutputController::ToggleLocalOutput() { … }
void OutputController::ProcessDeviceChange() { … }
std::pair<float, bool> OutputController::ReadCurrentPowerAndClip() { … }
void OutputController::SwitchAudioOutputDeviceId(
const std::string& new_output_device_id) { … }
}