private Port.Info getPortInfo(int portIndex, int type) { switch (type) { case SRC_UNKNOWN: return new PortInfo(nGetPortName(getID(), portIndex), true); case SRC_MICROPHONE: return Port.Info.MICROPHONE; case SRC_LINE_IN: return Port.Info.LINE_IN; case SRC_COMPACT_DISC: return Port.Info.COMPACT_DISC; case DST_UNKNOWN: return new PortInfo(nGetPortName(getID(), portIndex), false); case DST_SPEAKER: return Port.Info.SPEAKER; case DST_HEADPHONE: return Port.Info.HEADPHONE; case DST_LINE_OUT: return Port.Info.LINE_OUT; } // should never happen... if (Printer.debug) Printer.debug("unknown port type: "+type); return null; }
/** Obtain the value of a default provider property. @param typeClass The type of the default provider property. This should be one of Receiver.class, Transmitter.class, Sequencer.class, Synthesizer.class, SourceDataLine.class, TargetDataLine.class, Clip.class or Port.class. @return The complete value of the property, if available. If the property is not set, null is returned. */ private static synchronized String getDefaultProvider(Class typeClass) { if (!SourceDataLine.class.equals(typeClass) && !TargetDataLine.class.equals(typeClass) && !Clip.class.equals(typeClass) && !Port.class.equals(typeClass) && !Receiver.class.equals(typeClass) && !Transmitter.class.equals(typeClass) && !Synthesizer.class.equals(typeClass) && !Sequencer.class.equals(typeClass)) { return null; } String name = typeClass.getName(); String value = AccessController.doPrivileged( (PrivilegedAction<String>) () -> System.getProperty(name)); if (value == null) { value = getProperties().getProperty(name); } if ("".equals(value)) { value = null; } return value; }
/** Obtain the value of a default provider property. @param typeClass The type of the default provider property. This should be one of Receiver.class, Transmitter.class, Sequencer.class, Synthesizer.class, SourceDataLine.class, TargetDataLine.class, Clip.class or Port.class. @return The complete value of the property, if available. If the property is not set, null is returned. */ private static synchronized String getDefaultProvider(Class<?> typeClass) { if (!SourceDataLine.class.equals(typeClass) && !TargetDataLine.class.equals(typeClass) && !Clip.class.equals(typeClass) && !Port.class.equals(typeClass) && !Receiver.class.equals(typeClass) && !Transmitter.class.equals(typeClass) && !Synthesizer.class.equals(typeClass) && !Sequencer.class.equals(typeClass)) { return null; } String name = typeClass.getName(); String value = AccessController.doPrivileged( (PrivilegedAction<String>) () -> System.getProperty(name)); if (value == null) { value = getProperties().getProperty(name); } if ("".equals(value)) { value = null; } return value; }
/** Obtain the value of a default provider property. @param typeClass The type of the default provider property. This should be one of Receiver.class, Transmitter.class, Sequencer.class, Synthesizer.class, SourceDataLine.class, TargetDataLine.class, Clip.class or Port.class. @return The complete value of the property, if available. If the property is not set, null is returned. */ private static synchronized String getDefaultProvider(Class typeClass) { if (!SourceDataLine.class.equals(typeClass) && !TargetDataLine.class.equals(typeClass) && !Clip.class.equals(typeClass) && !Port.class.equals(typeClass) && !Receiver.class.equals(typeClass) && !Transmitter.class.equals(typeClass) && !Synthesizer.class.equals(typeClass) && !Sequencer.class.equals(typeClass)) { return null; } String value; String propertyName = typeClass.getName(); value = JSSecurityManager.getProperty(propertyName); if (value == null) { value = getProperties().getProperty(propertyName); } if ("".equals(value)) { value = null; } return value; }
public void testPortInfo() { assertEquals("COMPACT_DISC source port", Port.Info.COMPACT_DISC.toString()); assertEquals("LINE_OUT target port", Port.Info.LINE_OUT.toString()); Class<Port> cl = Port.class; String name = "name"; Port.Info pi1 = new Port.Info(cl, name, true); assertEquals(name, pi1.getName()); assertTrue(pi1.isSource()); Port.Info pi2 = new Port.Info(cl, name, true); assertFalse(pi1.equals(pi2)); assertTrue(pi1.equals(pi1)); assertTrue(pi1.matches(pi2)); assertTrue(pi2.matches(pi1)); pi2 = new Port.Info(cl, "name1", false); assertTrue(pi1.matches(pi1)); assertFalse(pi1.matches(pi2)); assertFalse(pi2.matches(pi1)); }
public void testPortInfo() { assertEquals("COMPACT_DISC source port", Port.Info.COMPACT_DISC.toString()); assertEquals("LINE_OUT target port", Port.Info.LINE_OUT.toString()); Class cl = Port.class; String name = "name"; Port.Info pi1 = new Port.Info(cl, name, true); assertEquals(name, pi1.getName()); assertTrue(pi1.isSource()); Port.Info pi2 = new Port.Info(cl, name, true); assertFalse(pi1.equals(pi2)); assertTrue(pi1.equals(pi1)); assertTrue(pi1.matches(pi2)); assertTrue(pi2.matches(pi1)); pi2 = new Port.Info(cl, "name1", false); assertTrue(pi1.matches(pi1)); assertFalse(pi1.matches(pi2)); assertFalse(pi2.matches(pi1)); }
private Line.Info[] getPortInfo(Mixer mixer) { Line.Info[] infos; List<Line.Info> portInfoList = new ArrayList<Line.Info>(); infos = mixer.getSourceLineInfo(); for (Line.Info info : infos) { if (info instanceof Port.Info || info instanceof DataLine.Info) { portInfoList.add((Line.Info) info); } } infos = mixer.getTargetLineInfo(); for (Line.Info info1 : infos) { if (info1 instanceof Port.Info || info1 instanceof DataLine.Info) { portInfoList.add((Line.Info) info1); } } return portInfoList.toArray(EMPTY_PORT_INFO_ARRAY); }
public Line getLine(Line.Info info) throws LineUnavailableException { Line.Info fullInfo = getLineInfo(info); if ((fullInfo != null) && (fullInfo instanceof Port.Info)) { for (int i = 0; i < portInfos.length; i++) { if (fullInfo.equals(portInfos[i])) { return getPort(i); } } } throw new IllegalArgumentException("Line unsupported: " + info); }
public int getMaxLines(Line.Info info) { Line.Info fullInfo = getLineInfo(info); // if it's not supported at all, return 0. if (fullInfo == null) { return 0; } if (fullInfo instanceof Port.Info) { //return AudioSystem.NOT_SPECIFIED; // if several instances of PortMixerPort return 1; } return 0; }
Port getPort(int index) { if (ports == null) { ports = new PortMixerPort[portInfos.length]; } if (ports[index] == null) { ports[index] = new PortMixerPort((Port.Info)portInfos[index], this, index); return ports[index]; } // $$fb TODO: return (Port) (ports[index].clone()); return ports[index]; }
private PortMixerPort(Port.Info info, PortMixer mixer, int portIndex) { super(info, mixer, null); if (Printer.trace) Printer.trace("PortMixerPort CONSTRUCTOR: info: " + info); this.portIndex = portIndex; }
@Override public Line getLine(Line.Info info) throws LineUnavailableException { Line.Info fullInfo = getLineInfo(info); if ((fullInfo != null) && (fullInfo instanceof Port.Info)) { for (int i = 0; i < portInfos.length; i++) { if (fullInfo.equals(portInfos[i])) { return getPort(i); } } } throw new IllegalArgumentException("Line unsupported: " + info); }
@Override public int getMaxLines(Line.Info info) { Line.Info fullInfo = getLineInfo(info); // if it's not supported at all, return 0. if (fullInfo == null) { return 0; } if (fullInfo instanceof Port.Info) { //return AudioSystem.NOT_SPECIFIED; // if several instances of PortMixerPort return 1; } return 0; }