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

#include <tqobject.h>
#include <tqptrlist.h>
#include <tqvaluelist.h>
#include <tqmap.h>
#include <tqstring.h>
#include <alsa/asoundlib.h>

#include "alsadevice.h"

class TQSocketNotifier;

struct AlsaCard {
    int     index;
    TQString name;
};

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

    bool open();
    void close();

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

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

private slots:
    void onMixerFd( int fd );

private:
    void openCard( int card );
    void addElement( int card, const TQString &cardName,
                     snd_mixer_elem_t *elem, AlsaDevice::Category cat );

    TQValueList<AlsaCard>      m_cards;
    TQPtrList<AlsaDevice>      m_devices;
    TQPtrList<TQSocketNotifier> m_notifiers;
    TQValueList<snd_mixer_t*>  m_mixers;
    TQMap<int, snd_mixer_t*>   m_fdToMixer;
};