#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/audio/pulse/pulse_util.h"
#include <stdint.h>
#include <string.h>
#include <memory>
#include <type_traits>
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/notreached.h"
#include "base/synchronization/waitable_event.h"
#include "build/branding_buildflags.h"
#include "media/audio/audio_device_description.h"
#include "media/base/audio_timestamp_helper.h"
#if defined(DLOPEN_PULSEAUDIO)
#include "media/audio/pulse/pulse_stubs.h"
kModulePulse;
InitializeStubs;
StubPathMap;
#endif
namespace media {
namespace pulse {
namespace {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
constexpr char kBrowserDisplayName[] = "google-chrome";
#define PRODUCT_STRING …
#else
constexpr char kBrowserDisplayName[] = …;
#define PRODUCT_STRING …
#endif
#if defined(DLOPEN_PULSEAUDIO)
static const base::FilePath::CharType kPulseLib[] = …);
#endif
void DestroyMainloop(pa_threaded_mainloop* mainloop) { … }
void DestroyContext(pa_context* context) { … }
pa_channel_position ChromiumToPAChannelPosition(Channels channel) { … }
class ScopedPropertyList { … };
struct InputBusData { … };
struct OutputBusData { … };
void InputBusCallback(pa_context* context,
const pa_source_info* info,
int error,
void* user_data) { … }
void OutputBusCallback(pa_context* context,
const pa_sink_info* info,
int error,
void* user_data) { … }
struct DefaultDevicesData { … };
void GetDefaultDeviceIdCallback(pa_context* c,
const pa_server_info* info,
void* userdata) { … }
struct MonitorSourceData { … };
void GetMonitorSourceNameForSinkCallback(pa_context* context,
const pa_sink_info* info,
int eol,
void* userdata) { … }
struct ContextStartupData { … };
void SignalReadyOrErrorStateCallback(pa_context* context, void* context_data) { … }
}
bool InitPulse(pa_threaded_mainloop** mainloop, pa_context** context) { … }
void DestroyPulse(pa_threaded_mainloop* mainloop, pa_context* context) { … }
void StreamSuccessCallback(pa_stream* s, int error, void* mainloop) { … }
void ContextSuccessCallback(pa_context* context, int success, void* mainloop) { … }
void ContextStateCallback(pa_context* context, void* mainloop) { … }
pa_channel_map ChannelLayoutToPAChannelMap(ChannelLayout channel_layout) { … }
bool WaitForOperationCompletion(pa_threaded_mainloop* mainloop,
pa_operation* operation,
pa_context* optional_context,
pa_stream* optional_stream) { … }
base::TimeDelta GetHardwareLatency(pa_stream* stream) { … }
#define RETURN_ON_FAILURE …
bool CreateInputStream(pa_threaded_mainloop* mainloop,
pa_context* context,
raw_ptr<pa_stream>* stream,
const AudioParameters& params,
const std::string& device_id,
pa_stream_notify_cb_t stream_callback,
void* user_data) { … }
bool CreateOutputStream(raw_ptr<pa_threaded_mainloop>* mainloop,
raw_ptr<pa_context>* context,
raw_ptr<pa_stream>* stream,
const AudioParameters& params,
const std::string& device_id,
const std::string& app_name,
pa_stream_notify_cb_t stream_callback,
pa_stream_request_cb_t write_callback,
void* user_data) { … }
std::string GetBusOfInput(pa_threaded_mainloop* mainloop,
pa_context* context,
const std::string& name) { … }
std::string GetOutputCorrespondingTo(pa_threaded_mainloop* mainloop,
pa_context* context,
const std::string& bus) { … }
std::string GetRealDefaultDeviceId(pa_threaded_mainloop* mainloop,
pa_context* context,
RequestType type) { … }
std::string GetMonitorSourceNameForSink(pa_threaded_mainloop* mainloop,
pa_context* context,
const std::string& sink_name) { … }
#undef RETURN_ON_FAILURE
}
}