summaryrefslogtreecommitdiff
path: root/src/model/ossmodel.h
blob: 8c3db8b582e21416c52aed021b58f48a75a83749 (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
#pragma once

#include <tqobject.h>
#include <tqptrlist.h>
#include <tqvaluelist.h>
#include <tqstring.h>

#include "ossdevice.h"

class TQTimer;

struct OssCard {
    int     index;
    TQString path;
    TQString name;
};

class OssModel : public TQObject
{
    TQ_OBJECT
public:
    explicit OssModel( TQObject *parent = 0 );
    ~OssModel();

    bool open();
    void close();

    TQValueList<OssCard>  cards()   const { return m_cards; }
    TQPtrList<OssDevice>  devices() const { return m_devices; }
    TQPtrList<OssDevice>  devicesForCard( int cardIdx ) const;
    OssDevice *defaultOutput() const;
    OssDevice *preferredOutput() const;
    void setPreferredOutput( int cardIdx, const TQString &name );

signals:
    void deviceAdded( OssDevice *dev );
    void preferredOutputChanged( OssDevice *dev );
    void ready();

private slots:
    void onPollTimer();

private:
    void openCard( int cardIdx, const TQString &path );

    TQValueList<OssCard>  m_cards;
    TQPtrList<OssDevice>  m_devices;
    TQValueList<int>      m_fds;    // one open fd per card, owned here
    TQTimer              *m_timer;
};