Jack2  1.9.9
JackOSSAdapter.h
1 /*
2 Copyright (C) 2008 Grame & RTL 2008
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __JackOSSAdapter__
21 #define __JackOSSAdapter__
22 
23 #include <math.h>
24 #include <limits.h>
25 #include <assert.h>
26 #include "JackAudioAdapterInterface.h"
27 #include "JackPlatformPlug.h"
28 #include "JackError.h"
29 #include "jack.h"
30 #include "jslist.h"
31 
32 namespace Jack
33 {
34 
35 typedef jack_default_audio_sample_t jack_sample_t;
36 
37 #define OSS_DRIVER_DEF_DEV "/dev/dsp"
38 #define OSS_DRIVER_DEF_FS 48000
39 #define OSS_DRIVER_DEF_BLKSIZE 1024
40 #define OSS_DRIVER_DEF_NPERIODS 2
41 #define OSS_DRIVER_DEF_BITS 16
42 #define OSS_DRIVER_DEF_INS 2
43 #define OSS_DRIVER_DEF_OUTS 2
44 
50 {
51 
52  enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
53 
54  private:
55 
56  JackThread fThread;
57 
58  char fCaptureDriverName[JACK_CLIENT_NAME_SIZE + 1];
59  char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE + 1];
60 
61  int fInFD;
62  int fOutFD;
63 
64  int fBits;
65  int fSampleFormat;
66  int fNperiods;
67  unsigned int fSampleSize;
68  int fRWMode;
69  bool fIgnoreHW;
70  bool fExcl;
71 
72  unsigned int fInputBufferSize;
73  unsigned int fOutputBufferSize;
74 
75  void* fInputBuffer;
76  void* fOutputBuffer;
77 
78  float** fInputSampleBuffer;
79  float** fOutputSampleBuffer;
80 
81  bool fFirstCycle;
82 
83  int OpenInput();
84  int OpenOutput();
85  void CloseAux();
86  void SetSampleFormat();
87  void DisplayDeviceInfo();
88 
89  public:
90 
91  JackOSSAdapter(jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params);
93  {}
94 
95  int Open();
96  int Close();
97 
98  int Read();
99  int Write();
100 
101  int SetBufferSize(jack_nframes_t buffer_size);
102 
103  bool Execute();
104 };
105 
106 }
107 
108 #ifdef __cplusplus
109 extern "C"
110 {
111 #endif
112 
113 #include "JackCompilerDeps.h"
114 #include "driver_interface.h"
115 
116 SERVER_EXPORT jack_driver_desc_t* jack_get_descriptor();
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif
The OSS adapter.
The base class for runnable objects, that have an Init and Execute method to be called in a threa...
Definition: JackThread.h:34
Base class for audio adapters.
Darwin threads. Real-time threads are actually &quot;time constraint&quot; threads.