Jack2  1.9.9
JackBoomerDriver.h
1 /*
2 Copyright (C) 2009 Grame
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 __JackBoomerDriver__
21 #define __JackBoomerDriver__
22 
23 #include "JackAudioDriver.h"
24 #include "JackPlatformPlug.h"
25 #include "ringbuffer.h"
26 #include <semaphore.h>
27 
28 namespace Jack
29 {
30 
31 typedef jack_default_audio_sample_t jack_sample_t;
32 
33 #define OSS_DRIVER_DEF_DEV "/dev/dsp"
34 #define OSS_DRIVER_DEF_FS 48000
35 #define OSS_DRIVER_DEF_BLKSIZE 1024
36 #define OSS_DRIVER_DEF_NPERIODS 1
37 #define OSS_DRIVER_DEF_BITS 16
38 #define OSS_DRIVER_DEF_INS 2
39 #define OSS_DRIVER_DEF_OUTS 2
40 
46 {
47 
48  enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
49 
50  private:
51 
52  class JackBoomerDriverInput : public JackRunnableInterface {
53 
54  private:
55 
56  JackBoomerDriver* fDriver;
57 
58  public:
59 
60  JackBoomerDriverInput(JackBoomerDriver* driver): fDriver(driver)
61  {}
62  ~JackBoomerDriverInput()
63  {}
64 
65  bool Init();
66  bool Execute();
67  };
68 
69  class JackBoomerDriverOutput : public JackRunnableInterface {
70 
71  private:
72 
73  JackBoomerDriver* fDriver;
74 
75  public:
76 
77  JackBoomerDriverOutput(JackBoomerDriver* driver): fDriver(driver)
78  {}
79  ~JackBoomerDriverOutput()
80  {}
81 
82  bool Init();
83  bool Execute();
84  };
85 
86  int fInFD;
87  int fOutFD;
88 
89  int fBits;
90  int fSampleFormat;
91  int fNperiods;
92  unsigned int fSampleSize;
93  unsigned int fFragmentSize;
94  int fRWMode;
95  bool fExcl;
96  bool fSyncIO;
97 
98  unsigned int fInputBufferSize;
99  unsigned int fOutputBufferSize;
100 
101  void* fInputBuffer;
102  void* fOutputBuffer;
103 
104  sem_t fReadSema;
105  sem_t fWriteSema;
106 
107  JackThread fInputThread;
108  JackThread fOutputThread;
109 
110  JackBoomerDriverInput fInputHandler;
111  JackBoomerDriverOutput fOutputHandler;
112 
113  int OpenInput();
114  int OpenOutput();
115  int OpenAux();
116  void CloseAux();
117  void SetSampleFormat();
118  void DisplayDeviceInfo();
119  void SynchronizeRead();
120  void SynchronizeWrite();
121 
122  public:
123 
124  JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
125  virtual ~JackBoomerDriver();
126 
127  int Open(jack_nframes_t frames_per_cycle,
128  int user_nperiods,
129  jack_nframes_t rate,
130  bool capturing,
131  bool playing,
132  int chan_in,
133  int chan_out,
134  bool excl,
135  bool monitor,
136  const char* capture_driver_name,
137  const char* playback_driver_name,
138  jack_nframes_t capture_latency,
139  jack_nframes_t playback_latency,
140  int bits, bool syncio);
141 
142  int Close();
143 
144  int Start();
145  int Stop();
146 
147  // BufferSize can be changed
148  bool IsFixedBufferSize()
149  {
150  return false;
151  }
152 
153  int SetBufferSize(jack_nframes_t buffer_size);
154 
155 };
156 
157 } // end of namespace
158 
159 #endif
Inter process synchronization using using Mach semaphore.
Locked Engine, access to methods is serialized using a mutex.
The base class for runnable objects, that have an Init and Execute method to be called in a threa...
Definition: JackThread.h:34
The base class for audio drivers: drivers with audio ports.
The Boomer driver.
Darwin threads. Real-time threads are actually &quot;time constraint&quot; threads.