29 |
|
|
30 |
namespace LinuxSampler { |
namespace LinuxSampler { |
31 |
|
|
32 |
// *************** ParameterName *************** |
/// number of currently existing JACK audio output devices in LinuxSampler |
33 |
|
static int existingJackDevices = 0; |
34 |
|
|
35 |
|
// *************** AudioChannelJack::ParameterName *************** |
36 |
// * |
// * |
37 |
|
|
38 |
AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) { |
AudioOutputDeviceJack::AudioChannelJack::ParameterName::ParameterName(AudioChannelJack* pChannel) : AudioChannel::ParameterName(ToString(pChannel->ChannelNr)) { |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
// *************** ParameterJackBindings *************** |
// *************** AudioChannelJack::ParameterJackBindings *************** |
49 |
// * |
// * |
50 |
|
|
51 |
AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) { |
AudioOutputDeviceJack::AudioChannelJack::ParameterJackBindings::ParameterJackBindings(AudioChannelJack* pChannel) : DeviceRuntimeParameterStrings(std::vector<String>()) { |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
// *************** AudioOutputDeviceJack::ParameterName *************** |
113 |
|
// * |
114 |
|
|
115 |
|
AudioOutputDeviceJack::ParameterName::ParameterName() : DeviceCreationParameterString() { |
116 |
|
InitWithDefault(); // use default name |
117 |
|
} |
118 |
|
|
119 |
|
AudioOutputDeviceJack::ParameterName::ParameterName(String s) throw (LinuxSamplerException) : DeviceCreationParameterString(s) { |
120 |
|
} |
121 |
|
|
122 |
|
String AudioOutputDeviceJack::ParameterName::Description() { |
123 |
|
return "Arbitrary JACK client name"; |
124 |
|
} |
125 |
|
|
126 |
|
bool AudioOutputDeviceJack::ParameterName::Fix() { |
127 |
|
return true; |
128 |
|
} |
129 |
|
|
130 |
|
bool AudioOutputDeviceJack::ParameterName::Mandatory() { |
131 |
|
return false; |
132 |
|
} |
133 |
|
|
134 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDeviceJack::ParameterName::DependsAsParameters() { |
135 |
|
return std::map<String,DeviceCreationParameter*>(); // no dependencies |
136 |
|
} |
137 |
|
|
138 |
|
std::vector<String> AudioOutputDeviceJack::ParameterName::PossibilitiesAsString(std::map<String,String> Parameters) { |
139 |
|
return std::vector<String>(); |
140 |
|
} |
141 |
|
|
142 |
|
optional<String> AudioOutputDeviceJack::ParameterName::DefaultAsString(std::map<String,String> Parameters) { |
143 |
|
return (existingJackDevices) ? "LinuxSampler" + ToString(existingJackDevices) : "LinuxSampler"; |
144 |
|
} |
145 |
|
|
146 |
|
void AudioOutputDeviceJack::ParameterName::OnSetValue(String s) throw (LinuxSamplerException) { |
147 |
|
// not possible, as parameter is fix |
148 |
|
} |
149 |
|
|
150 |
|
String AudioOutputDeviceJack::ParameterName::Name() { |
151 |
|
return "NAME"; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
// *************** AudioOutputDeviceJack *************** |
// *************** AudioOutputDeviceJack *************** |
157 |
// * |
// * |
158 |
|
|
164 |
* @see AcquireChannels() |
* @see AcquireChannels() |
165 |
*/ |
*/ |
166 |
AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) { |
AudioOutputDeviceJack::AudioOutputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) { |
167 |
if ((hJackClient = jack_client_new("LinuxSampler")) == 0) |
if (((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().size() >= jack_client_name_size()) |
168 |
|
throw LinuxSamplerException("JACK client name too long"); |
169 |
|
|
170 |
|
if ((hJackClient = jack_client_new(((DeviceCreationParameterString*)Parameters["NAME"])->ValueAsString().c_str())) == 0) |
171 |
throw AudioOutputException("Seems Jack server not running."); |
throw AudioOutputException("Seems Jack server not running."); |
172 |
|
|
173 |
|
existingJackDevices++; |
174 |
|
|
175 |
jack_set_process_callback(hJackClient, __libjack_process_callback, this); |
jack_set_process_callback(hJackClient, __libjack_process_callback, this); |
176 |
jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this); |
jack_on_shutdown(hJackClient, __libjack_shutdown_callback, this); |
177 |
if (jack_activate(hJackClient)) |
if (jack_activate(hJackClient)) |
189 |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
AudioOutputDeviceJack::~AudioOutputDeviceJack() { |
190 |
// destroy jack client |
// destroy jack client |
191 |
jack_client_close(hJackClient); |
jack_client_close(hJackClient); |
192 |
|
existingJackDevices--; |
193 |
} |
} |
194 |
|
|
195 |
/** |
/** |
244 |
} |
} |
245 |
|
|
246 |
String AudioOutputDeviceJack::Version() { |
String AudioOutputDeviceJack::Version() { |
247 |
String s = "$Revision: 1.14 $"; |
String s = "$Revision: 1.15 $"; |
248 |
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 |
249 |
} |
} |
250 |
|
|