Jack2  1.9.9
JackPortAudioDriver.h
1 /*
2 Copyright (C) 2004-2008 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 __JackPortAudioDriver__
21 #define __JackPortAudioDriver__
22 
23 #include "JackAudioDriver.h"
24 #include "JackPortAudioDevices.h"
25 #include "JackMMCSS.h"
26 
27 namespace Jack
28 {
29 
35 {
36 
37  private:
38 
39  PortAudioDevices* fPaDevices;
40  PaStream* fStream;
41  jack_default_audio_sample_t** fInputBuffer;
42  jack_default_audio_sample_t** fOutputBuffer;
43  PaDeviceIndex fInputDevice;
44  PaDeviceIndex fOutputDevice;
45 
46  static int Render(const void* inputBuffer, void* outputBuffer,
47  unsigned long framesPerBuffer,
48  const PaStreamCallbackTimeInfo* timeInfo,
49  PaStreamCallbackFlags statusFlags,
50  void* userData);
51 
52  PaError OpenStream(jack_nframes_t buffer_size);
53  void UpdateLatencies();
54 
55  public:
56 
57  JackPortAudioDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, PortAudioDevices* pa_devices)
58  : JackMMCSS(), JackAudioDriver(name, alias, engine, table), fStream(NULL), fInputBuffer(NULL), fOutputBuffer(NULL),
59  fInputDevice(paNoDevice), fOutputDevice(paNoDevice)
60  {
61  fPaDevices = pa_devices;
62  }
63 
64  virtual ~JackPortAudioDriver()
65  {
66  delete fPaDevices;
67  }
68 
69  int Open(jack_nframes_t buffe_size,
70  jack_nframes_t samplerate,
71  bool capturing,
72  bool playing,
73  int chan_in,
74  int chan_out,
75  bool monitor,
76  const char* capture_driver_name,
77  const char* playback_driver_name,
78  jack_nframes_t capture_latency,
79  jack_nframes_t playback_latency);
80 
81  int Close();
82 
83  int Attach();
84 
85  int Start();
86  int Stop();
87 
88  int Read();
89  int Write();
90 
91  // BufferSize can be changed
92  bool IsFixedBufferSize()
93  {
94  return false;
95  }
96 
97  int SetBufferSize(jack_nframes_t buffer_size);
98 };
99 
100 } // end of namespace
101 
102 #endif
MMCSS services.
Definition: JackMMCSS.h:48
Inter process synchronization using using Mach semaphore.
Locked Engine, access to methods is serialized using a mutex.
void PaStream
Definition: portaudio.h:572
int PaDeviceIndex
Definition: portaudio.h:153
The PortAudio driver.
The base class for audio drivers: drivers with audio ports.
int PaError
Definition: portaudio.h:63
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:646
#define paNoDevice
Definition: portaudio.h:161
A PortAudio Devices manager.