summaryrefslogtreecommitdiff
path: root/src/model/pulsedevice.h
blob: fbdf98500b61910a5eb61838972aee4727f14bb4 (plain)
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
#pragma once

#include <pulse/pulseaudio.h>
#include "audiodevice.h"

class PulseDevice : public AudioDevice
{
    TQ_OBJECT

public:
    PulseDevice( AudioDevice::Category cat, uint32_t paIndex, TQObject *parent = 0 );
    ~PulseDevice() {}

    TQString     name()     const { return m_name; }
    Category    category() const { return m_category; }
    int         volume()   const { return m_volume; }
    bool        muted()    const { return m_muted; }
    uint32_t    paIndex()  const { return m_paIndex; }

    void setVolume( int v );
    void setMuted( bool m );

    // Called by PulseModel when PA reports an update — updates in place and emits signals.
    void update( const TQString &name, int volume, bool muted );

    TQWidget *createWidget( TQWidget *parent );

    // PA context needed to write volume back — set once by PulseModel after construction.
    void setPAContext( pa_context *ctx, pa_threaded_mainloop *mainloop );

private:
    AudioDevice::Category  m_category;
    uint32_t               m_paIndex;
    TQString                m_name;
    int                    m_volume;   // 0-100
    bool                   m_muted;

    pa_context            *m_context;
    pa_threaded_mainloop  *m_mainloop;
};