#ifndef MEDIA_AUDIO_PULSE_PULSE_UTIL_H_
#define MEDIA_AUDIO_PULSE_PULSE_UTIL_H_
#include <pulse/pulseaudio.h>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "media/audio/audio_device_name.h"
#include "media/base/audio_parameters.h"
#include "media/base/channel_layout.h"
namespace media {
class AudioParameters;
namespace pulse {
enum class RequestType : int8_t { … };
class AutoPulseLock { … };
bool MEDIA_EXPORT 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 = nullptr,
pa_stream* optional_stream = nullptr);
base::TimeDelta GetHardwareLatency(pa_stream* stream);
constexpr SampleFormat kInputSampleFormat = …;
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);
}
}
#endif