Jack2 1.9.12

JackOSSDriver.h
1 /*
2 Copyright (C) 2003-2007 Jussi Laako <jussi@sonarnerd.net>
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
43 class JackOSSDriver : public JackAudioDriver
44 {
45
46 enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
47
48 private:
49
50 int fInFD;
51 int fOutFD;
52
53 int fBits;
54 int fSampleFormat;
55 int fNperiods;
56 unsigned int fSampleSize;
57 int fRWMode;
58 bool fExcl;
59 bool fIgnoreHW;
60
61 unsigned int fInputBufferSize;
62 unsigned int fOutputBufferSize;
63
64 void* fInputBuffer;
65 void* fOutputBuffer;
66
67 bool fFirstCycle;
68
69 int OpenInput();
70 int OpenOutput();
71 int OpenAux();
72 void CloseAux();
73 void SetSampleFormat();
74 void DisplayDeviceInfo();
75
76 // Redefining since timing for CPU load is specific
77 int ProcessSync();
78
79 public:
80
81 JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
82 : JackAudioDriver(name, alias, engine, table),
83 fInFD(-1), fOutFD(-1), fBits(0),
84 fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
85 fInputBufferSize(0), fOutputBufferSize(0),
86 fInputBuffer(NULL), fOutputBuffer(NULL), fFirstCycle(true)
87 {}
88
89 virtual ~JackOSSDriver()
90 {}
91
92 int Open(jack_nframes_t frames_per_cycle,
93 int user_nperiods,
94 jack_nframes_t rate,
95 bool capturing,
96 bool playing,
97 int chan_in,
98 int chan_out,
99 bool vmix,
100 bool monitor,
101 const char* capture_driver_name,
102 const char* playback_driver_name,
103 jack_nframes_t capture_latency,
104 jack_nframes_t playback_latency,
105 int bits,
106 bool ignorehwbuf);
107
108 int Close();
109
110 int Read();
111 int Write();
112
113 // BufferSize can be changed
114 bool IsFixedBufferSize()
115 {
116 return false;
117 }
118
119 int SetBufferSize(jack_nframes_t buffer_size);
120
121 };
122
123 } // end of namespace
124
125 #endif
Jack::JackLockedEngine
Locked Engine, access to methods is serialized using a mutex.
Definition: JackLockedEngine.h:78
Jack::JackPosixSemaphore
Inter process synchronization using POSIX semaphore.
Definition: JackPosixSemaphore.h:36
Jack::JackAudioDriver
The base class for audio drivers: drivers with audio ports.
Definition: JackAudioDriver.h:42
Jack::JackOSSDriver
The OSS driver.
Definition: JackOSSDriver.h:43