#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/audio/alsa/alsa_output.h"
#include <stddef.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/free_deleter.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/typed_macros.h"
#include "media/audio/alsa/alsa_util.h"
#include "media/audio/alsa/alsa_wrapper.h"
#include "media/audio/alsa/audio_manager_alsa.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/channel_mixer.h"
#include "media/base/data_buffer.h"
#include "media/base/seekable_buffer.h"
namespace media {
#if defined(NDEBUG)
static const int kPcmRecoverIsSilent = 1;
#else
static const int kPcmRecoverIsSilent = …;
#endif
static const ChannelLayout kDefaultOutputChannelLayout = …;
static const char* GuessSpecificDeviceName(uint32_t channels) { … }
std::ostream& operator<<(std::ostream& os,
AlsaPcmOutputStream::InternalState state) { … }
static const SampleFormat kSampleFormat = …;
static const snd_pcm_format_t kAlsaSampleFormat = …;
const char AlsaPcmOutputStream::kDefaultDevice[] = …;
const char AlsaPcmOutputStream::kAutoSelectDevice[] = …;
const char AlsaPcmOutputStream::kPlugPrefix[] = …;
const uint32_t AlsaPcmOutputStream::kMinLatencyMicros = …;
AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
const AudioParameters& params,
AlsaWrapper* wrapper,
AudioManagerBase* manager)
: … { … }
AlsaPcmOutputStream::~AlsaPcmOutputStream() { … }
bool AlsaPcmOutputStream::Open() { … }
void AlsaPcmOutputStream::Close() { … }
void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) { … }
void AlsaPcmOutputStream::Stop() { … }
void AlsaPcmOutputStream::Flush() { … }
void AlsaPcmOutputStream::SetVolume(double volume) { … }
void AlsaPcmOutputStream::GetVolume(double* volume) { … }
void AlsaPcmOutputStream::SetTickClockForTesting(
const base::TickClock* tick_clock) { … }
void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) { … }
void AlsaPcmOutputStream::WritePacket() { … }
void AlsaPcmOutputStream::WriteTask() { … }
void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) { … }
std::string AlsaPcmOutputStream::FindDeviceForChannels(uint32_t channels) { … }
snd_pcm_sframes_t AlsaPcmOutputStream::GetCurrentDelay() { … }
snd_pcm_sframes_t AlsaPcmOutputStream::GetAvailableFrames() { … }
snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) { … }
bool AlsaPcmOutputStream::CanTransitionTo(InternalState to) { … }
AlsaPcmOutputStream::InternalState
AlsaPcmOutputStream::TransitionTo(InternalState to) { … }
AlsaPcmOutputStream::InternalState AlsaPcmOutputStream::state() { … }
int AlsaPcmOutputStream::RunDataCallback(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
AudioBus* audio_bus) { … }
void AlsaPcmOutputStream::RunErrorCallback(int code) { … }
void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { … }
}