chromium/media/audio/pulse/pulse_util.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/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  // defined(DLOPEN_PULSEAUDIO)

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 {};

// Callback used by GetMonitorSourceNameForSink(). `info` contains information
// about the queried sink, in particular, the name of the source which acts as a
// monitor for the sink.
void GetMonitorSourceNameForSinkCallback(pa_context* context,
                                         const pa_sink_info* info,
                                         int eol,
                                         void* userdata) {}

struct ContextStartupData {};

void SignalReadyOrErrorStateCallback(pa_context* context, void* context_data) {}

}  // namespace

bool InitPulse(pa_threaded_mainloop** mainloop, pa_context** context) {}

void DestroyPulse(pa_threaded_mainloop* mainloop, pa_context* context) {}

// static, pa_stream_success_cb_t
void StreamSuccessCallback(pa_stream* s, int error, void* mainloop) {}

// pa_context_success_cb_t
void ContextSuccessCallback(pa_context* context, int success, void* mainloop) {}

// |pa_context| and |pa_stream| state changed cb.
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) {}

// Helper macro for CreateInput/OutputStream() to avoid code spam and
// string bloat.
#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

}  // namespace pulse

}  // namespace media