23#include <pulse/pulseaudio.h>
24#include <pulse/stream.h>
80 const std::string& baseline;
92 const std::string& baseline;
125 bool inSinkList(
const std::string& deviceName);
140 static void context_changed_callback(
pa_context* c,
147 static void source_input_info_callback(
pa_context* c,
151 static void sink_input_info_callback(
pa_context* c,
159 virtual int getIndexCapture()
const;
160 virtual int getIndexPlayback()
const;
161 virtual int getIndexRingtone()
const;
163 void waitForDevices();
164 void waitForDeviceList();
166 std::string getPreferredPlaybackDevice()
const;
167 std::string getPreferredRingtoneDevice()
const;
168 std::string getPreferredCaptureDevice()
const;
192 void disconnectAudioStream();
193 void onStreamReady();
199 const PaDeviceInfos* getDeviceInfos(
const std::vector<PaDeviceInfos>&,
200 const std::string& name)
const;
202 std::atomic_uint pendingStreams {0};
207 std::unique_ptr<AudioStream> playback_;
212 std::unique_ptr<AudioStream> record_;
217 std::unique_ptr<AudioStream> ringtone_;
222 std::vector<PaDeviceInfos> sinkList_ {};
227 std::vector<PaDeviceInfos> sourceList_ {};
231 std::string defaultSink_ {};
232 std::string defaultSource_ {};
237 bool enumeratingSinks_ {
false};
238 bool enumeratingSources_ {
false};
239 bool gettingServerInfo_ {
false};
240 std::atomic_bool waitingDeviceList_ {
false};
241 std::mutex readyMtx_ {};
242 std::condition_variable readyCv_ {};
243 std::thread streamStarter_ {};
bool operator()(const PaDeviceInfos &arg)
DescriptionComparator(const std::string &ref)
Unary function to search for a device by name in a list using std functions.
bool operator()(const PaDeviceInfos &arg)
NameComparator(const std::string &ref)
virtual void stopStream(AudioDeviceType stream=AudioDeviceType::ALL)
Stop the playback and capture streams.
std::string getAudioDeviceName(int index, AudioDeviceType type) const
friend class AudioLayerTest
virtual std::vector< std::string > getPlaybackDeviceList() const
virtual std::vector< std::string > getCaptureDeviceList() const
bool inSourceList(const std::string &deviceName)
virtual void startStream(AudioDeviceType stream=AudioDeviceType::ALL)
Start the capture stream and prepare the playback stream.
void readFromMic()
Write data from the ring buffer to the hardware and read data from the hardware.
int getAudioDeviceIndex(const std::string &descr, AudioDeviceType type) const
int getAudioDeviceIndexByName(const std::string &name, AudioDeviceType type) const
bool inSinkList(const std::string &deviceName)
void emitSignal(Args... args)
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Convenience structure to hold PulseAudio device propreties such as supported channel number etc.
pa_sample_spec sample_spec
pa_channel_map channel_map
PaDeviceInfos(const pa_source_info &source)
PaDeviceInfos(const pa_sink_info &source)