summaryrefslogtreecommitdiff
path: root/src/model/pulsedevice.h
blob: e974508d4cb78fd35898292125a61e40e0ca0a25 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

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

class PulseModel;

class PulseDevice : public AudioDevice
{
    TQ_OBJECT

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

    TQString     name()     const { return m_name; }
    TQString     iconName() const { return m_iconName; }
    Category    category() const { return m_category; }
    int         volume()   const { return m_volume; }
    bool        muted()    const { return m_muted; }
    int         pan()      const { return m_pan; }
    uint32_t    paIndex()     const { return m_paIndex; }
    uint32_t    sinkIndex()   const { return m_sinkIndex; }
    TQString     monitorName() const { return m_monitorName; }
    TQString     paName()      const { return m_paName; }

    void setPaName( const TQString &n )    { m_paName    = n; }
    void setSinkIndex( uint32_t idx )      { m_sinkIndex = idx; }
    void setModel( PulseModel *m )         { m_model = m; }
    void adjustRecordingCount( int delta );

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

    void update( const TQString &name, int volume, bool muted,
                 uint8_t channels, int pan,
                 const TQString &monitorName, const TQString &iconName );

    TQWidget *createWidget( TQWidget *parent );

    void setPAContext( pa_context *ctx, pa_threaded_mainloop *mainloop );
    void detach();   // called by PulseModel before tearing down the mainloop

protected:
    void customEvent( TQCustomEvent *e );

private:
    void startMonitoring();
    static void monitorReadCb( pa_stream *s, size_t nbytes, void *userdata );

    AudioDevice::Category  m_category;
    uint32_t               m_paIndex;
    uint32_t               m_sinkIndex;
    TQString                m_name;
    TQString                m_iconName;
    int                    m_volume;
    bool                   m_muted;
    int                    m_pan;
    uint8_t                m_channels;

    pa_context            *m_context;
    pa_threaded_mainloop  *m_mainloop;

    TQString                m_monitorName;
    pa_stream             *m_monitorStream;
    TQString                m_paName;
    PulseModel            *m_model;
    int                    m_recordingCount;
};