23 |
#include "AudioOutputDeviceJack.h" |
#include "AudioOutputDeviceJack.h" |
24 |
#include "AudioOutputDeviceFactory.h" |
#include "AudioOutputDeviceFactory.h" |
25 |
|
|
26 |
#if HAVE_JACK |
#include <errno.h> |
|
|
|
|
namespace LinuxSampler { |
|
27 |
|
|
28 |
REGISTER_AUDIO_OUTPUT_DRIVER(AudioOutputDeviceJack); |
#if HAVE_JACK |
29 |
|
|
30 |
/* Common parameters for now they'll have to be registered here. */ |
#ifndef HAVE_JACK_CLIENT_NAME_SIZE |
31 |
REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterActive); |
#define jack_client_name_size() 33 |
32 |
REGISTER_AUDIO_OUTPUT_DRIVER_PARAMETER(AudioOutputDeviceJack, ParameterChannels); |
#endif |
33 |
|
|
34 |
|
namespace LinuxSampler { |
35 |
|
|
36 |
|
/// number of currently existing JACK audio output devices in LinuxSampler |
37 |
|
static int existingJackDevices = 0; |
38 |
|
|
39 |
// *************** ParameterName *************** |
// *************** AudioChannelJack::ParameterName *************** |
40 |
// * |
// * |
41 |
|
|
42 |
AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) { |
AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) { |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
// *************** ParameterJackBindings *************** |
// *************** AudioChannelJack::ParameterJackBindings *************** |
53 |
// * |
// * |
54 |
|
|
55 |
AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) { |
AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) { |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
// *************** AudioOutputDeviceJack::ParameterName *************** |
117 |
|
// * |
118 |
|
|
119 |
|
AudioOutputDeviceJack::ParameterName::ParameterName() : DeviceCreationParameterString() { |
120 |
|
InitWithDefault(); // use default name |
121 |
|
} |
122 |
|
|
123 |
|
AudioOutputDeviceJack::ParameterName::ParameterName(String s) throw (LinuxSamplerException) : DeviceCreationParameterString(s) { |
124 |
|
} |
125 |
|
|
126 |
|
String AudioOutputDeviceJack::ParameterName::Description() { |
127 |
|
return "Arbitrary JACK client name"; |
128 |
|
} |
129 |
|
|
130 |
|
bool AudioOutputDeviceJack::ParameterName::Fix() { |
131 |
|
return true; |
132 |
|
} |
133 |
|
|
134 |
|
bool AudioOutputDeviceJack::ParameterName::Mandatory() { |
135 |
|
return false; |
136 |
|
} |
137 |
|
|
138 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDeviceJack::ParameterName::DependsAsParameters() { |
139 |
|
return std::map<String,DeviceCreationParameter*>(); // no dependencies |
140 |
|
} |
141 |
|
|
142 |
|
std::vector<String> AudioOutputDeviceJack::ParameterName::PossibilitiesAsString(std::map<String,String> Parameters) { |
143 |
|
return std::vector<String>(); |
144 |
|
} |
145 |
|
|
146 |
|
optional<String> AudioOutputDeviceJack::ParameterName::DefaultAsString(std::map<String,String> Parameters) { |
147 |
|
return (existingJackDevices) ? "LinuxSampler" + ToString(existingJackDevices) : "LinuxSampler"; |
148 |
|
} |
149 |
|
|
150 |
|
void AudioOutputDeviceJack::ParameterName::OnSetValue(String s) throw (LinuxSamplerException) { |
151 |
|
// not possible, as parameter is fix |
152 |
|
} |
153 |
|
|
154 |
|
String AudioOutputDeviceJack::ParameterName::Name() { |
155 |
|
return "NAME"; |
156 |
|
} |
157 |
|
|
158 |
|
|
159 |
|
|
160 |
// *************** AudioOutputDeviceJack *************** |
// *************** AudioOutputDeviceJack *************** |
161 |
// * |
// * |
162 |
|
|
168 |
* @see AcquireChannels() |
* @see AcquireChannels() |
169 |
*/ |
*/ |
170 |
AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) { |
AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) { |
171 |
if ((hJackClient = jack_client_new("LinuxSampler")) == 0) |
if (((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().size() >= jack_client_name_size()) |
172 |
|
throw LinuxSamplerException("JACK client name too long"); |
173 |
|
|
174 |
|
if ((hJackClient = jack_client_new(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().c_str())) == 0) |
175 |
throw AudioOutputException("Seems Jack server not running."); |
throw AudioOutputException("Seems Jack server not running."); |
176 |
|
|
177 |
|
existingJackDevices++; |
178 |
|
|
179 |
jack_set_process_callback(hJackClient, __libjack_process_callback, this); |
jack_set_process_callback(hJackClient, __libjack_process_callback, this); |
180 |
jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this); |
jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this); |
181 |
if (jack_activate(hJackClient)) |
if (jack_activate(hJackClient)) |
193 |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
194 |
// destroy jack client |
// destroy jack client |
195 |
jack_client_close(hJackClient); |
jack_client_close(hJackClient); |
196 |
|
existingJackDevices--; |
197 |
} |
} |
198 |
|
|
199 |
/** |
/** |
248 |
} |
} |
249 |
|
|
250 |
String AudioOutputDeviceJack::Version() { |
String AudioOutputDeviceJack::Version() { |
251 |
String s = "$Revision: 1.12 $"; |
String s = "$Revision: 1.16 $"; |
252 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
253 |
} |
} |
254 |
|
|