3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2013 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
40 |
#endif |
#endif |
41 |
|
|
42 |
namespace LinuxSampler { |
namespace LinuxSampler { |
43 |
|
|
44 |
|
class JackClient; |
45 |
|
class JackListener; |
46 |
|
|
47 |
/** JACK audio output driver |
/** JACK audio output driver |
48 |
* |
* |
89 |
protected: |
protected: |
90 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
91 |
~AudioChannelJack(); |
~AudioChannelJack(); |
92 |
|
void UpdateJackBuffer(uint size); |
93 |
friend class AudioOutputDeviceJack; |
friend class AudioOutputDeviceJack; |
94 |
private: |
private: |
95 |
AudioOutputDeviceJack* pDevice; |
AudioOutputDeviceJack* pDevice; |
125 |
virtual uint MaxSamplesPerCycle(); |
virtual uint MaxSamplesPerCycle(); |
126 |
virtual uint SampleRate(); |
virtual uint SampleRate(); |
127 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
128 |
|
virtual float latency(); |
129 |
|
|
130 |
static String Name(); |
static String Name(); |
131 |
|
|
135 |
static String Version(); |
static String Version(); |
136 |
|
|
137 |
int Process(uint Samples); // FIXME: should be private |
int Process(uint Samples); // FIXME: should be private |
138 |
|
void UpdateJackBuffers(uint size); |
139 |
|
void addListener(JackListener* listener); |
140 |
|
jack_client_t* jackClientHandle(); |
141 |
protected: |
protected: |
142 |
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
143 |
private: |
private: |
144 |
ConditionServer csIsPlaying; |
ConditionServer csIsPlaying; |
145 |
uint uiMaxSamplesPerCycle; |
uint uiMaxSamplesPerCycle; |
146 |
jack_client_t* hJackClient; |
jack_client_t* hJackClient; |
147 |
|
JackClient* pJackClient; |
148 |
}; |
}; |
149 |
|
|
150 |
// Callback functions for the libjack API |
// Callback functions for the libjack API |
151 |
int linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg); |
int linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg); |
|
void linuxsampler_libjack_shutdown_callback(void* arg); |
|
|
|
|
152 |
|
|
153 |
/** JACK client |
/** JACK client |
154 |
* |
* |
170 |
#if HAVE_JACK_MIDI |
#if HAVE_JACK_MIDI |
171 |
void SetMidiInputDevice(MidiInputDeviceJack* device); |
void SetMidiInputDevice(MidiInputDeviceJack* device); |
172 |
#endif |
#endif |
173 |
|
void addListener(JackListener* listener); |
174 |
|
|
175 |
jack_client_t* hJackClient; |
jack_client_t* hJackClient; |
176 |
|
|
177 |
private: |
private: |
178 |
|
std::vector<JackListener*> jackListeners; |
179 |
static std::map<String, JackClient*> Clients; |
static std::map<String, JackClient*> Clients; |
180 |
struct config_t { |
struct config_t { |
181 |
AudioOutputDeviceJack* AudioDevice; |
AudioOutputDeviceJack* AudioDevice; |
190 |
|
|
191 |
JackClient(String Name); |
JackClient(String Name); |
192 |
~JackClient(); |
~JackClient(); |
193 |
|
|
194 |
|
// Callback functions for the libjack API |
195 |
|
static void libjackShutdownCallback(void* arg); |
196 |
|
static int libjackSampleRateCallback(jack_nframes_t nframes, void *arg); |
197 |
|
static int libjackBufferSizeCallback(jack_nframes_t nframes, void *arg); |
198 |
|
}; |
199 |
|
|
200 |
|
/** |
201 |
|
* Currently not derived / instantiated by the sampler itself, however this |
202 |
|
* class can be subclassed and used i.e. by a GUI build on top of the sampler, |
203 |
|
* to react on JACK events. Because registering JACK callback functions through |
204 |
|
* the general JACK API is not possible after the JACK client has been activated, |
205 |
|
* and the latter is already the case as soon as an AudioOutputDeviceJack object |
206 |
|
* has been instantiated. |
207 |
|
*/ |
208 |
|
class JackListener { |
209 |
|
public: |
210 |
|
virtual void onJackShutdown() = 0; |
211 |
}; |
}; |
212 |
} |
} |
213 |
|
|