Jack2 1.9.12

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