aboutsummaryrefslogtreecommitdiffstats
path: root/oss.h
blob: 1cb128b1e1e849455b47442f1b2a28b2c0eadd05 (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
#ifndef OSS_H
#define OSS_H

#include <qobject.h>
#include <qsocketnotifier.h>

/* ---------------------------------------------------------------------- */

#define STATUS_CLOSED    0
#define STATUS_RECORD    1
#define STATUS_PLAYBACK  2

class Soundcard : public QObject
{
    Q_OBJECT;

private:
    /* sound card capabilities */
    char devname[32];
    int  init_done;
    int  afmt_hw;
    int  afmt_sw;
    int  channels_hw;

    int  trigger;
    char driver_name[64];

    /* current settings */
    int  afmt;
    int  channels;
    int  rate;
    int  blocksize;
    int  latency;

    /* file handle, reference count */
    int  fd, stat;
    char buffer[65536];
    QSocketNotifier *telmi;
    
    /* internal functions */
    void get_capabilities();
    int  open_dev(int record);
    void close_dev();

public:
    Soundcard(const char *dev);
    ~Soundcard();
    char *driver();
    void setparams(struct SOUNDPARAMS *params);
    int  start_record();
    int  start_playback();
    int  kill_buffer();
    int  stop();

    int  has_channels();      /* # of channels (1=mono,2=stereo) */
    int  has_format(int f);   /* check format availibity         */ 

public slots:
    void sounddata(int);
    
signals:
    void senddata(void *data);
    /* !!! only one should be connected to receivedata !!! */
    void receivedata(void *data);
    void newparams(struct SOUNDPARAMS *params);
};

#endif