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 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 * |
24 |
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
#ifndef __LS_AUDIOOUTPUTDEVICEJACK_H__ |
25 |
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
#define __LS_AUDIOOUTPUTDEVICEJACK_H__ |
26 |
|
|
27 |
#include "../../common/global.h" |
#include "../../common/global_private.h" |
28 |
|
|
29 |
#if HAVE_JACK |
#if HAVE_JACK |
30 |
|
|
35 |
#include "AudioOutputDevice.h" |
#include "AudioOutputDevice.h" |
36 |
#include "../../common/ConditionServer.h" |
#include "../../common/ConditionServer.h" |
37 |
|
|
38 |
|
#if HAVE_JACK_MIDI |
39 |
|
#include "../midi/MidiInputDeviceJack.h" |
40 |
|
#endif |
41 |
|
|
42 |
namespace LinuxSampler { |
namespace LinuxSampler { |
43 |
|
|
44 |
/** JACK audio output driver |
/** JACK audio output driver |
86 |
protected: |
protected: |
87 |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
AudioChannelJack(uint ChannelNr, AudioOutputDeviceJack* pDevice) throw (AudioOutputException); |
88 |
~AudioChannelJack(); |
~AudioChannelJack(); |
89 |
|
void UpdateJackBuffer(uint size); |
90 |
friend class AudioOutputDeviceJack; |
friend class AudioOutputDeviceJack; |
91 |
private: |
private: |
92 |
AudioOutputDeviceJack* pDevice; |
AudioOutputDeviceJack* pDevice; |
104 |
class ParameterName : public DeviceCreationParameterString { |
class ParameterName : public DeviceCreationParameterString { |
105 |
public: |
public: |
106 |
ParameterName(); |
ParameterName(); |
107 |
ParameterName(String s) throw (LinuxSamplerException); |
ParameterName(String s) throw (Exception); |
108 |
virtual String Description(); |
virtual String Description(); |
109 |
virtual bool Fix(); |
virtual bool Fix(); |
110 |
virtual bool Mandatory(); |
virtual bool Mandatory(); |
111 |
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
112 |
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
113 |
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
114 |
virtual void OnSetValue(String s) throw (LinuxSamplerException); |
virtual void OnSetValue(String s) throw (Exception); |
115 |
static String Name(); |
static String Name(); |
116 |
}; |
}; |
117 |
|
|
122 |
virtual uint MaxSamplesPerCycle(); |
virtual uint MaxSamplesPerCycle(); |
123 |
virtual uint SampleRate(); |
virtual uint SampleRate(); |
124 |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
virtual AudioChannel* CreateChannel(uint ChannelNr); |
125 |
|
virtual float latency(); |
126 |
|
|
127 |
|
static String Name(); |
|
static String Name(); |
|
128 |
|
|
129 |
virtual String Driver(); |
virtual String Driver(); |
130 |
|
|
132 |
static String Version(); |
static String Version(); |
133 |
|
|
134 |
int Process(uint Samples); // FIXME: should be private |
int Process(uint Samples); // FIXME: should be private |
135 |
|
void UpdateJackBuffers(uint size); |
136 |
protected: |
protected: |
137 |
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
AudioOutputDeviceJack(String* AutoConnectPortIDs = NULL, uint AutoConnectPorts = 0); |
138 |
private: |
private: |
142 |
}; |
}; |
143 |
|
|
144 |
// Callback functions for the libjack API |
// Callback functions for the libjack API |
145 |
int __libjack_process_callback(jack_nframes_t nframes, void* arg); |
int linuxsampler_libjack_process_callback(jack_nframes_t nframes, void* arg); |
146 |
void __libjack_shutdown_callback(void* arg); |
void linuxsampler_libjack_shutdown_callback(void* arg); |
147 |
|
|
148 |
|
|
149 |
|
/** JACK client |
150 |
|
* |
151 |
|
* Represents a jack client. This class is shared by |
152 |
|
* AudioOutputDeviceJack and MidiInputDeviceJack. The jack server |
153 |
|
* calls JackClient::Process, which in turn calls |
154 |
|
* AudioOutputDeviceJack::Process and/or |
155 |
|
* MidiInputDeviceJack::Process. |
156 |
|
*/ |
157 |
|
class JackClient { |
158 |
|
public: |
159 |
|
static JackClient* CreateAudio(String Name); |
160 |
|
static JackClient* CreateMidi(String Name); |
161 |
|
static void ReleaseAudio(String Name); |
162 |
|
static void ReleaseMidi(String Name); |
163 |
|
int Process(uint Samples); |
164 |
|
void Stop(); |
165 |
|
void SetAudioOutputDevice(AudioOutputDeviceJack* device); |
166 |
|
#if HAVE_JACK_MIDI |
167 |
|
void SetMidiInputDevice(MidiInputDeviceJack* device); |
168 |
|
#endif |
169 |
|
|
170 |
|
jack_client_t* hJackClient; |
171 |
|
|
172 |
|
private: |
173 |
|
static std::map<String, JackClient*> Clients; |
174 |
|
struct config_t { |
175 |
|
AudioOutputDeviceJack* AudioDevice; |
176 |
|
#if HAVE_JACK_MIDI |
177 |
|
MidiInputDeviceJack* MidiDevice; |
178 |
|
#endif |
179 |
|
}; |
180 |
|
SynchronizedConfig<config_t> Config; |
181 |
|
SynchronizedConfig<config_t>::Reader ConfigReader; |
182 |
|
bool audio; |
183 |
|
bool midi; |
184 |
|
|
185 |
|
JackClient(String Name); |
186 |
|
~JackClient(); |
187 |
|
|
188 |
|
// Callback functions for the libjack API |
189 |
|
static int libjackSampleRateCallback(jack_nframes_t nframes, void *arg); |
190 |
|
static int libjackBufferSizeCallback(jack_nframes_t nframes, void *arg); |
191 |
|
}; |
192 |
} |
} |
193 |
|
|
194 |
#endif // HAVE_JACK |
#endif // HAVE_JACK |