Debian Codegraph @

freebsd/oss/JackOSSDriver.h

raw
1 /*
2 Copyright (C) 2003-2007 Jussi Laako <[email protected]>
3 Copyright (C) 2008 Grame & RTL 2008
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __JackOSSDriver__
22 #define __JackOSSDriver__
23
24 #include "JackAudioDriver.h"
25
26 namespace Jack
27 {
28
29 typedef jack_default_audio_sample_t jack_sample_t;
30
31 #define OSS_DRIVER_DEF_DEV "/dev/dsp"
32 #define OSS_DRIVER_DEF_FS 48000
33 #define OSS_DRIVER_DEF_BLKSIZE 1024
34 #define OSS_DRIVER_DEF_NPERIODS 1
35 #define OSS_DRIVER_DEF_BITS 16
36 #define OSS_DRIVER_DEF_INS 2
37 #define OSS_DRIVER_DEF_OUTS 2
38
39 /*!
40 \brief The OSS driver.
41 */
42
43 class JackOSSDriver : public JackAudioDriver
44 {
45 private:
46
47 int fInFD;
48 int fOutFD;
49
50 int fBits;
51 int fNperiods;
52 bool fCapture;
53 bool fPlayback;
54 bool fExcl;
55 bool fIgnoreHW;
56
57 unsigned int fInSampleSize;
58 unsigned int fOutSampleSize;
59
60 unsigned int fInputBufferSize;
61 unsigned int fOutputBufferSize;
62
63 void* fInputBuffer;
64 void* fOutputBuffer;
65
66 jack_nframes_t fInBlockSize;
67 jack_nframes_t fOutBlockSize;
68 jack_nframes_t fInMeanStep;
69 jack_nframes_t fOutMeanStep;
70 jack_nframes_t fOSSInBuffer;
71 jack_nframes_t fOSSOutBuffer;
72
73 jack_time_t fOSSReadSync;
74 long long fOSSReadOffset;
75 jack_time_t fOSSWriteSync;
76 long long fOSSWriteOffset;
77
78 // Buffer balance and sync correction
79 long long fBufferBalance;
80 bool fForceBalancing;
81 bool fForceSync;
82
83 int OpenInput();
84 int OpenOutput();
85 int OpenAux();
86 void CloseAux();
87 void DisplayDeviceInfo();
88 int ProbeInBlockSize();
89 int ProbeOutBlockSize();
90 int Discard(jack_nframes_t frames);
91 int WriteSilence(jack_nframes_t frames);
92 int WaitAndSync();
93
94 protected:
95 virtual void UpdateLatencies();
96
97 public:
98
99 JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
100 : JackAudioDriver(name, alias, engine, table),
101 fInFD(-1), fOutFD(-1), fBits(0),
102 fNperiods(0), fCapture(false), fPlayback(false), fExcl(false), fIgnoreHW(true),
103 fInSampleSize(0), fOutSampleSize(0),
104 fInputBufferSize(0), fOutputBufferSize(0),
105 fInputBuffer(NULL), fOutputBuffer(NULL),
106 fInBlockSize(1), fOutBlockSize(1),
107 fInMeanStep(0), fOutMeanStep(0),
108 fOSSInBuffer(0), fOSSOutBuffer(0),
109 fOSSReadSync(0), fOSSReadOffset(0), fOSSWriteSync(0), fOSSWriteOffset(0),
110 fBufferBalance(0), fForceBalancing(false), fForceSync(false)
111 {}
112
113 virtual ~JackOSSDriver()
114 {}
115
116 int Open(jack_nframes_t frames_per_cycle,
117 int user_nperiods,
118 jack_nframes_t rate,
119 bool capturing,
120 bool playing,
121 int chan_in,
122 int chan_out,
123 bool vmix,
124 bool monitor,
125 const char* capture_driver_name,
126 const char* playback_driver_name,
127 jack_nframes_t capture_latency,
128 jack_nframes_t playback_latency,
129 int bits,
130 bool ignorehwbuf);
131
132 int Close();
133
134 int Read();
135 int Write();
136
137 // BufferSize can be changed
138 bool IsFixedBufferSize()
139 {
140 return false;
141 }
142
143 int SetBufferSize(jack_nframes_t buffer_size);
144
145 };
146
147 } // end of namespace
148
149 #endif