236
237 // CONSTRUCTOR
238 private PortMixerPort(Port.Info info,
239 PortMixer mixer,
240 int portIndex) {
241 super(info, mixer, null);
242 if (Printer.trace) Printer.trace("PortMixerPort CONSTRUCTOR: info: " + info);
243 this.portIndex = portIndex;
244 }
245
246
247 // ABSTRACT METHOD IMPLEMENTATIONS
248
249 // ABSTRACT LINE
250
251 void implOpen() throws LineUnavailableException {
252 if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
253 long newID = ((PortMixer) mixer).getID();
254 if ((id == 0) || (newID != id) || (controls.length == 0)) {
255 id = newID;
256 Vector vector = new Vector();
257 synchronized (vector) {
258 nGetControls(id, portIndex, vector);
259 controls = new Control[vector.size()];
260 for (int i = 0; i < controls.length; i++) {
261 controls[i] = (Control) vector.elementAt(i);
262 }
263 }
264 } else {
265 enableControls(controls, true);
266 }
267 if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded");
268 }
269
270 private void enableControls(Control[] controls, boolean enable) {
271 for (int i = 0; i < controls.length; i++) {
272 if (controls[i] instanceof BoolCtrl) {
273 ((BoolCtrl) controls[i]).closed = !enable;
274 }
275 else if (controls[i] instanceof FloatCtrl) {
276 ((FloatCtrl) controls[i]).closed = !enable;
277 }
278 else if (controls[i] instanceof CompoundControl) {
279 enableControls(((CompoundControl) controls[i]).getMemberControls(), enable);
280 }
281 }
477 private static final class PortInfo extends Port.Info {
478 private PortInfo(String name, boolean isSource) {
479 super(Port.class, name, isSource);
480 }
481 }
482
483 // open the mixer with the given index. Returns a handle ID
484 private static native long nOpen(int mixerIndex) throws LineUnavailableException;
485 private static native void nClose(long id);
486
487 // gets the number of ports for this mixer
488 private static native int nGetPortCount(long id);
489
490 // gets the type of the port with this index
491 private static native int nGetPortType(long id, int portIndex);
492
493 // gets the name of the port with this index
494 private static native String nGetPortName(long id, int portIndex);
495
496 // fills the vector with the controls for this port
497 private static native void nGetControls(long id, int portIndex, Vector vector);
498
499 // getters/setters for controls
500 private static native void nControlSetIntValue(long controlID, int value);
501 private static native int nControlGetIntValue(long controlID);
502 private static native void nControlSetFloatValue(long controlID, float value);
503 private static native float nControlGetFloatValue(long controlID);
504
505 }
|
236
237 // CONSTRUCTOR
238 private PortMixerPort(Port.Info info,
239 PortMixer mixer,
240 int portIndex) {
241 super(info, mixer, null);
242 if (Printer.trace) Printer.trace("PortMixerPort CONSTRUCTOR: info: " + info);
243 this.portIndex = portIndex;
244 }
245
246
247 // ABSTRACT METHOD IMPLEMENTATIONS
248
249 // ABSTRACT LINE
250
251 void implOpen() throws LineUnavailableException {
252 if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
253 long newID = ((PortMixer) mixer).getID();
254 if ((id == 0) || (newID != id) || (controls.length == 0)) {
255 id = newID;
256 Vector<Control> vector = new Vector<>();
257 synchronized (vector) {
258 nGetControls(id, portIndex, vector);
259 controls = new Control[vector.size()];
260 for (int i = 0; i < controls.length; i++) {
261 controls[i] = vector.elementAt(i);
262 }
263 }
264 } else {
265 enableControls(controls, true);
266 }
267 if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded");
268 }
269
270 private void enableControls(Control[] controls, boolean enable) {
271 for (int i = 0; i < controls.length; i++) {
272 if (controls[i] instanceof BoolCtrl) {
273 ((BoolCtrl) controls[i]).closed = !enable;
274 }
275 else if (controls[i] instanceof FloatCtrl) {
276 ((FloatCtrl) controls[i]).closed = !enable;
277 }
278 else if (controls[i] instanceof CompoundControl) {
279 enableControls(((CompoundControl) controls[i]).getMemberControls(), enable);
280 }
281 }
477 private static final class PortInfo extends Port.Info {
478 private PortInfo(String name, boolean isSource) {
479 super(Port.class, name, isSource);
480 }
481 }
482
483 // open the mixer with the given index. Returns a handle ID
484 private static native long nOpen(int mixerIndex) throws LineUnavailableException;
485 private static native void nClose(long id);
486
487 // gets the number of ports for this mixer
488 private static native int nGetPortCount(long id);
489
490 // gets the type of the port with this index
491 private static native int nGetPortType(long id, int portIndex);
492
493 // gets the name of the port with this index
494 private static native String nGetPortName(long id, int portIndex);
495
496 // fills the vector with the controls for this port
497 @SuppressWarnings("rawtypes")
498 private static native void nGetControls(long id, int portIndex, Vector vector);
499
500 // getters/setters for controls
501 private static native void nControlSetIntValue(long controlID, int value);
502 private static native int nControlGetIntValue(long controlID);
503 private static native void nControlSetFloatValue(long controlID, float value);
504 private static native float nControlGetFloatValue(long controlID);
505
506 }
|