1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#pragma once
#include <tqobject.h>
#include <tqptrlist.h>
#include <pulse/pulseaudio.h>
#include "audiodevice.h"
class PulseDevice;
class PulseModel : public TQObject
{
TQ_OBJECT
public:
explicit PulseModel( TQObject *parent = 0 );
~PulseModel();
bool open();
void close();
TQPtrList<AudioDevice> devices( AudioDevice::Category cat ) const;
protected:
void customEvent( TQCustomEvent *e );
signals:
void deviceAdded( AudioDevice *dev );
void deviceRemoved( AudioDevice *dev );
void ready(); // emitted once initial enumeration is complete
private:
static void contextStateCb( pa_context *c, void *userdata );
static void sinkInfoCb( pa_context *c, const pa_sink_info *info, int eol, void *userdata );
static void sourceInfoCb( pa_context *c, const pa_source_info *info, int eol, void *userdata );
static void sinkInputInfoCb( pa_context *c, const pa_sink_input_info *info, int eol, void *userdata );
static void sourceOutputInfoCb( pa_context *c, const pa_source_output_info *info, int eol, void *userdata );
static void subscribeCb( pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata );
void enumerateAll();
void addOrUpdateSink( const pa_sink_info *info );
void addOrUpdateSource( const pa_source_info *info );
void addOrUpdateSinkInput( const pa_sink_input_info *info );
void addOrUpdateSourceOutput( const pa_source_output_info *info );
void removeDevice( AudioDevice::Category cat, uint32_t paIndex );
pa_threaded_mainloop *m_mainloop;
pa_context *m_context;
// Keyed by PA index within each category — stable objects, updated in place.
TQPtrList<PulseDevice> m_sinks;
TQPtrList<PulseDevice> m_sources;
TQPtrList<PulseDevice> m_sinkInputs;
TQPtrList<PulseDevice> m_sourceOutputs;
PulseDevice *findDevice( TQPtrList<PulseDevice> &list, uint32_t paIndex );
};
|