1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
22 |
|
|
23 |
package org.jsampler.task; |
package org.jsampler.task; |
24 |
|
|
|
import java.util.logging.Level; |
|
|
|
|
25 |
import org.jsampler.AudioDeviceModel; |
import org.jsampler.AudioDeviceModel; |
26 |
import org.jsampler.CC; |
import org.jsampler.CC; |
|
import org.jsampler.HF; |
|
27 |
import org.jsampler.SamplerModel; |
import org.jsampler.SamplerModel; |
28 |
|
|
29 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
54 |
} |
} |
55 |
|
|
56 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
57 |
|
@Override |
58 |
public void |
public void |
59 |
run() { |
exec() throws Exception { setResult(CC.getClient().getAudioOutputDrivers()); } |
|
try { setResult(CC.getClient().getAudioOutputDrivers()); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
60 |
} |
} |
61 |
|
|
62 |
/** |
/** |
81 |
} |
} |
82 |
|
|
83 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
84 |
|
@Override |
85 |
public void |
public void |
86 |
run() { |
exec() throws Exception { |
87 |
try { |
AudioOutputDriver d; |
88 |
AudioOutputDriver d; |
d = CC.getClient().getAudioOutputDriverInfo(driver, depList); |
89 |
d = CC.getClient().getAudioOutputDriverInfo(driver, depList); |
setResult(d.getParameters()); |
|
setResult(d.getParameters()); |
|
|
} |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
90 |
} |
} |
91 |
} |
} |
92 |
|
|
113 |
} |
} |
114 |
|
|
115 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
116 |
|
@Override |
117 |
public void |
public void |
118 |
run() { |
exec() throws Exception { |
119 |
try { |
Integer deviceId = CC.getClient().createAudioOutputDevice(driver, parameters); |
120 |
Integer deviceId = |
setResult(deviceId); |
|
CC.getClient().createAudioOutputDevice(driver, parameters); |
|
|
setResult(deviceId); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
121 |
} |
} |
122 |
} |
} |
123 |
|
|
141 |
} |
} |
142 |
|
|
143 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
144 |
|
@Override |
145 |
public void |
public void |
146 |
run() { |
exec() throws Exception { CC.getClient().destroyAudioOutputDevice(deviceId); } |
|
try { CC.getClient().destroyAudioOutputDevice(deviceId); } |
|
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
|
} |
|
147 |
} |
} |
148 |
|
|
149 |
/** |
/** |
169 |
} |
} |
170 |
|
|
171 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
172 |
|
@Override |
173 |
public void |
public void |
174 |
run() { |
exec() throws Exception { |
175 |
try { |
CC.getClient().enableAudioOutputDevice(dev, enable); |
|
CC.getClient().enableAudioOutputDevice(dev, enable); |
|
176 |
|
|
177 |
// Not needed, but eventually speeds up the change. |
// Not needed, but eventually speeds up the change. |
178 |
CC.getSamplerModel().getAudioDeviceById(dev).setActive(enable); |
CC.getSamplerModel().getAudioDeviceById(dev).setActive(enable); |
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
179 |
} |
} |
180 |
} |
} |
181 |
|
|
201 |
} |
} |
202 |
|
|
203 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
204 |
|
@Override |
205 |
public void |
public void |
206 |
run() { |
exec() throws Exception { |
207 |
try { CC.getClient().setAudioOutputDeviceParameter(dev, prm); } |
CC.getClient().setAudioOutputDeviceParameter(dev, prm); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
208 |
} |
} |
209 |
} |
} |
210 |
|
|
233 |
} |
} |
234 |
|
|
235 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
236 |
|
@Override |
237 |
public void |
public void |
238 |
run() { |
exec() throws Exception { |
239 |
try { CC.getClient().setAudioOutputChannelParameter(dev, channel, prm); } |
CC.getClient().setAudioOutputChannelParameter(dev, channel, prm); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
240 |
} |
} |
241 |
} |
} |
242 |
|
|
262 |
} |
} |
263 |
|
|
264 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
265 |
|
@Override |
266 |
public void |
public void |
267 |
run() { |
exec() throws Exception { |
268 |
try { CC.getClient().setAudioOutputChannelCount(deviceId, channels); } |
CC.getClient().setAudioOutputChannelCount(deviceId, channels); |
|
catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
269 |
} |
} |
270 |
} |
} |
271 |
|
|
289 |
} |
} |
290 |
|
|
291 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
292 |
|
@Override |
293 |
public void |
public void |
294 |
run() { |
exec() throws Exception { |
295 |
try { |
AudioOutputDevice d = CC.getClient().getAudioOutputDeviceInfo(dev); |
296 |
AudioOutputDevice d = CC.getClient().getAudioOutputDeviceInfo(dev); |
CC.getSamplerModel().getAudioDeviceById(dev).setDeviceInfo(d); |
|
CC.getSamplerModel().getAudioDeviceById(dev).setDeviceInfo(d); |
|
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
|
} |
|
297 |
} |
} |
298 |
} |
} |
299 |
|
|
309 |
} |
} |
310 |
|
|
311 |
/** The entry point of the task. */ |
/** The entry point of the task. */ |
312 |
|
@Override |
313 |
public void |
public void |
314 |
run() { |
exec() throws Exception { |
315 |
try { |
SamplerModel sm = CC.getSamplerModel(); |
316 |
SamplerModel sm = CC.getSamplerModel(); |
Integer[] devIDs = CC.getClient().getAudioOutputDeviceIDs(); |
317 |
Integer[] devIDs = CC.getClient().getAudioOutputDeviceIDs(); |
|
318 |
|
boolean found = false; |
319 |
|
|
320 |
boolean found = false; |
for(AudioDeviceModel m : sm.getAudioDevices()) { |
321 |
|
for(int i = 0; i < devIDs.length; i++) { |
322 |
for(AudioDeviceModel m : sm.getAudioDevices()) { |
if(m.getDeviceId() == devIDs[i]) { |
323 |
for(int i = 0; i < devIDs.length; i++) { |
devIDs[i] = -1; |
324 |
if(m.getDeviceId() == devIDs[i]) { |
found = true; |
|
devIDs[i] = -1; |
|
|
found = true; |
|
|
} |
|
325 |
} |
} |
|
|
|
|
if(!found) sm.removeAudioDeviceById(m.getDeviceId()); |
|
|
found = false; |
|
326 |
} |
} |
327 |
|
|
328 |
AudioOutputDevice d; |
if(!found) sm.removeAudioDeviceById(m.getDeviceId()); |
329 |
|
found = false; |
330 |
for(int id : devIDs) { |
} |
331 |
if(id >= 0) { |
|
332 |
d = CC.getClient().getAudioOutputDeviceInfo(id); |
AudioOutputDevice d; |
333 |
sm.addAudioDevice(d); |
|
334 |
} |
for(int id : devIDs) { |
335 |
|
if(id >= 0) { |
336 |
|
d = CC.getClient().getAudioOutputDeviceInfo(id); |
337 |
|
sm.addAudioDevice(d); |
338 |
} |
} |
|
} catch(Exception x) { |
|
|
setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x)); |
|
|
CC.getLogger().log(Level.FINE, getErrorMessage(), x); |
|
339 |
} |
} |
340 |
} |
} |
341 |
} |
} |