51
51
typedef struct PaDeviceInfos {
54
std::string description;
54
55
pa_sample_spec sample_spec;
55
56
pa_channel_map channel_map;
57
PaDeviceInfos(unsigned idx, const char* ep_name, const pa_sample_spec &samp_spec, const pa_channel_map &chan_map)
58
: index(idx), name(ep_name), sample_spec(samp_spec), channel_map(chan_map) {}
59
virtual ~PaDeviceInfos() {}
58
PaDeviceInfos(const pa_source_info& source) :
61
description(source.description),
62
sample_spec(source.sample_spec),
63
channel_map(source.channel_map) {}
65
PaDeviceInfos(const pa_sink_info& source) :
68
description(source.description),
69
sample_spec(source.sample_spec),
70
channel_map(source.channel_map) {}
62
73
* Unary function to search for a device by name in a list using std functions.
64
class nameComparator {
75
class NameComparator {
66
explicit nameComparator(const std::string &ref) : baseline(ref) {}
77
explicit NameComparator(const std::string &ref) : baseline(ref) {}
67
78
bool operator()(const PaDeviceInfos &arg) {
68
79
return arg.name == baseline;
71
82
const std::string &baseline;
85
class DescriptionComparator {
87
explicit DescriptionComparator(const std::string &ref) : baseline(ref) {}
88
bool operator()(const PaDeviceInfos &arg) {
89
return arg.description == baseline;
92
const std::string &baseline;
75
96
class PulseMainLoopLock {
96
117
void writeToSpeaker();
97
118
void ringtoneToSpeaker();
100
120
void updateSinkList();
102
121
void updateSourceList();
104
123
bool inSinkList(const std::string &deviceName);
106
124
bool inSourceList(const std::string &deviceName);
108
126
virtual std::vector<std::string> getCaptureDeviceList() const;
109
127
virtual std::vector<std::string> getPlaybackDeviceList() const;
110
int getAudioDeviceIndex(const std::string& name) const;
128
int getAudioDeviceIndex(const std::string& descr, DeviceType type) const;
129
int getAudioDeviceIndexByName(const std::string& name, DeviceType type) const;
112
std::string getAudioDeviceName(int index, PCMType type) const;
131
std::string getAudioDeviceName(int index, DeviceType type) const;
114
133
virtual void startStream();
116
134
virtual void stopStream();
127
145
const pa_sink_info *i,
128
146
int eol, void *userdata);
130
virtual void updatePreference(AudioPreference &pref, int index, PCMType type);
148
virtual void updatePreference(AudioPreference &pref, int index, DeviceType type);
132
150
virtual int getIndexCapture() const;
133
151
virtual int getIndexPlayback() const;
147
165
void disconnectAudioStream();
168
* Returns a pointer to the PaEndpointInfos with the given name in sourceList_, or nullptr if not found.
170
const PaDeviceInfos* getDeviceInfos(const std::vector<PaDeviceInfos>&, const std::string& name) const;
150
173
* A stream object to handle the pulseaudio playback stream
152
175
AudioStream* playback_;
172
195
std::vector<PaDeviceInfos> sourceList_;
175
* Returns a pointer to the PaEndpointInfos with the given name in sourceList_, or nullptr if not found.
177
const PaDeviceInfos* getDeviceInfos(const std::vector<PaDeviceInfos>&, const std::string& name) const;
180
198
* Buffers used to avoid doing malloc/free in the audio thread