JackBoomerDriver.h 3.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Copyright (C) 2009 Grame

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __JackBoomerDriver__
#define __JackBoomerDriver__

#include "JackAudioDriver.h"
24
#include "JackPlatformPlug.h"
25
#include "ringbuffer.h"
26
//#include "JackThread.h"
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

namespace Jack
{

typedef jack_default_audio_sample_t jack_sample_t;

#define OSS_DRIVER_N_PARAMS	13
#define OSS_DRIVER_DEF_DEV	"/dev/dsp"
#define OSS_DRIVER_DEF_FS	48000
#define OSS_DRIVER_DEF_BLKSIZE	1024
#define OSS_DRIVER_DEF_NPERIODS	1
#define OSS_DRIVER_DEF_BITS	16
#define OSS_DRIVER_DEF_INS	2
#define OSS_DRIVER_DEF_OUTS	2

/*!
43
\brief The Boomer driver.
44
45
*/

46
class JackBoomerDriver : public JackAudioDriver, public JackRunnableInterface
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{

    enum { kRead = 1, kWrite = 2, kReadWrite = 3 };

    private:
    
        int fInFD;
        int fOutFD;
        
        int fBits;
        int fSampleFormat;
        int fNperiods;
        unsigned int fSampleSize;
        int fRWMode;
        bool fExcl;
        bool fIgnoreHW;
        
        unsigned int fInputBufferSize;
        unsigned int fOutputBufferSize;
        
        void* fInputBuffer;
        void* fOutputBuffer;
69
70
        jack_ringbuffer_t** fRingBuffer;
        JackThread fThread;
71
         
72
73
74
75
76
77
78
79
        int OpenInput();
        int OpenOutput();
        int OpenAux();
        void CloseAux();
        void SetSampleFormat();
        void DisplayDeviceInfo();

        // Redefining since timing for CPU load is specific
80
        int ProcessAsync();
81
82
83
84
85
86
87
88

    public:

        JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
                : JackAudioDriver(name, alias, engine, table),
                fInFD(-1), fOutFD(-1), fBits(0), 
                fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
                fInputBufferSize(0), fOutputBufferSize(0),
89
90
91
                fInputBuffer(NULL), fOutputBuffer(NULL),
                fRingBuffer(NULL), fThread(this)
       {}
92
93

        virtual ~JackBoomerDriver()
94
        {}
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

        int Open(jack_nframes_t frames_per_cycle,
                 int user_nperiods, 
                 jack_nframes_t rate,
                 bool capturing,
                 bool playing,
                 int chan_in,
                 int chan_out,
                 bool vmix,
                 bool monitor,
                 const char* capture_driver_name,
                 const char* playback_driver_name,
                 jack_nframes_t capture_latency,
                 jack_nframes_t playback_latency,
                 int bits,
                 bool ignorehwbuf);

        int Close();

114
115
116
        int Start();
        int Stop();

117
118
119
120
121
122
123
124
125
126
        int Read();
        int Write();

        // BufferSize can be changed
        bool IsFixedBufferSize()
        {
            return false;
        }

        int SetBufferSize(jack_nframes_t buffer_size);
127
128
129
        
        bool Init();
        bool Execute();
130
131
132
133
134
135

};

} // end of namespace

#endif