类javax.sound.sampled.Port源码实例Demo

下面列出了怎么用javax.sound.sampled.Port的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: PortMixer.java
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;
}
 
源代码2 项目: TencentKona-8   文件: JDK13Services.java
/** 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;
}
 
源代码3 项目: jdk8u60   文件: PortMixer.java
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;
}
 
源代码4 项目: openjdk-jdk8u   文件: PortMixer.java
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;
}
 
源代码5 项目: openjdk-jdk8u   文件: JDK13Services.java
/** 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;
}
 
源代码6 项目: openjdk-8-source   文件: JDK13Services.java
/** 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;
}
 
源代码7 项目: openjdk-8   文件: PortMixer.java
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;
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: PortMixer.java
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;
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: JDK13Services.java
/** 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;
}
 
源代码10 项目: Bytecoder   文件: PortMixer.java
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.err) Printer.err("unknown port type: "+type);
    return null;
}
 
源代码11 项目: openjdk-jdk9   文件: PortMixer.java
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;
}
 
源代码12 项目: openjdk-jdk9   文件: JDK13Services.java
/** 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;
}
 
源代码13 项目: jdk8u-jdk   文件: PortMixer.java
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;
}
 
源代码14 项目: jdk8u-jdk   文件: JDK13Services.java
/** 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;
}
 
源代码15 项目: hottub   文件: PortMixer.java
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;
}
 
源代码16 项目: jdk8u_jdk   文件: JDK13Services.java
/** 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;
}
 
源代码17 项目: jdk8u_jdk   文件: PortMixer.java
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;
}
 
源代码18 项目: dragonwell8_jdk   文件: PortMixer.java
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);
}
 
源代码19 项目: dragonwell8_jdk   文件: PortMixer.java
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;
}
 
源代码20 项目: dragonwell8_jdk   文件: PortMixer.java
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];
}
 
源代码21 项目: dragonwell8_jdk   文件: PortMixer.java
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;
}
 
/**
 * Starting a Thread that checks if the resources needed to the
 * SpeechRecognition library are available
 */
protected void startResourcesThread() {

	// alive?
	if (resourcesThread != null && resourcesThread.isAlive())
		return;

	resourcesThread = new Thread(() -> {
		try {

			// Detect if the microphone is available
			while (true) {
				if (AudioSystem.isLineSupported(Port.Info.MICROPHONE)) {
					// logger.log(Level.INFO, "Microphone is available.\n")
				} else {
					// logger.log(Level.INFO, "Microphone is not
					// available.\n")

				}

				// Sleep some period
				Thread.sleep(350);
			}

		} catch (InterruptedException ex) {
			logger.log(Level.WARNING, null, ex);
			resourcesThread.interrupt();
		}
	});

	// Start
	resourcesThread.start();
}
 
源代码23 项目: jdk8u_jdk   文件: PortMixer.java
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;
}
 
源代码24 项目: TencentKona-8   文件: PortMixer.java
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);
}
 
源代码25 项目: TencentKona-8   文件: PortMixer.java
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;
}
 
/**
 * Starting a Thread that checks if the resources needed to the
 * SpeechRecognition library are available
 */
protected void startResourcesThread() {

	// alive?
	if (resourcesThread != null && resourcesThread.isAlive())
		return;

	resourcesThread = new Thread(() -> {
		try {

			// Detect if the microphone is available
			while (true) {
				if (AudioSystem.isLineSupported(Port.Info.MICROPHONE)) {
					// logger.log(Level.INFO, "Microphone is available.\n")
				} else {
					// logger.log(Level.INFO, "Microphone is not
					// available.\n")

				}

				// Sleep some period
				Thread.sleep(350);
			}

		} catch (InterruptedException ex) {
			logger.log(Level.WARNING, null, ex);
			resourcesThread.interrupt();
		}
	});

	// Start
	resourcesThread.start();
}
 
源代码27 项目: TencentKona-8   文件: PortMixer.java
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];
}
 
源代码28 项目: TencentKona-8   文件: PortMixer.java
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;
}
 
源代码29 项目: jdk8u60   文件: PortMixer.java
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);
}
 
源代码30 项目: jdk8u60   文件: PortMixer.java
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;
}