Java Code Examples for javax.sound.sampled.Line#Info

The following examples show how to use javax.sound.sampled.Line#Info . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMixer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the first complete Line.Info object it finds that
 * matches the one specified, or null if no matching Line.Info
 * object is found.
 */
final Line.Info getLineInfo(Line.Info info) {
    if (info == null) {
        return null;
    }
    // $$kk: 05.31.99: need to change this so that
    // the format and buffer size get set in the
    // returned info object for data lines??
    for (int i = 0; i < sourceLineInfo.length; i++) {
        if (info.matches(sourceLineInfo[i])) {
            return sourceLineInfo[i];
        }
    }

    for (int i = 0; i < targetLineInfo.length; i++) {
        if (info.matches(targetLineInfo[i])) {
            return targetLineInfo[i];
        }
    }

    return null;
}
 
Example 2
Source File: AbstractMixer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final Line.Info[] getTargetLineInfo(Line.Info info) {

    int i;
    Vector<Line.Info> vec = new Vector<>();

    for (i = 0; i < targetLineInfo.length; i++) {

        if (info.matches(targetLineInfo[i])) {
            vec.addElement(targetLineInfo[i]);
        }
    }

    Line.Info[] returnedArray = new Line.Info[vec.size()];
    for (i = 0; i < returnedArray.length; i++) {
        returnedArray[i] = vec.elementAt(i);
    }

    return returnedArray;
}
 
Example 3
Source File: AbstractMixer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public final boolean isLineSupported(Line.Info info) {

        int i;

        for (i = 0; i < sourceLineInfo.length; i++) {

            if (info.matches(sourceLineInfo[i])) {
                return true;
            }
        }

        for (i = 0; i < targetLineInfo.length; i++) {

            if (info.matches(targetLineInfo[i])) {
                return true;
            }
        }

        return false;
    }
 
Example 4
Source File: AbstractMixer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public final boolean isLineSupported(Line.Info info) {

        int i;

        for (i = 0; i < sourceLineInfo.length; i++) {

            if (info.matches(sourceLineInfo[i])) {
                return true;
            }
        }

        for (i = 0; i < targetLineInfo.length; i++) {

            if (info.matches(targetLineInfo[i])) {
                return true;
            }
        }

        return false;
    }
 
Example 5
Source File: PortMixer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: AbstractLine.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new AbstractLine.
 * @param mixer the mixer with which this line is associated
 * @param controls set of supported controls
 */
protected AbstractLine(Line.Info info, AbstractMixer mixer, Control[] controls) {

    if (controls == null) {
        controls = new Control[0];
    }

    this.info = info;
    this.mixer = mixer;
    this.controls = controls;
}
 
Example 7
Source File: SoftMixingMixer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public Line getLine(Line.Info info) throws LineUnavailableException {

    if (!isLineSupported(info))
        throw new IllegalArgumentException("Line unsupported: " + info);

    if ((info.getLineClass() == SourceDataLine.class)) {
        return new SoftMixingSourceDataLine(this, (DataLine.Info) info);
    }
    if ((info.getLineClass() == Clip.class)) {
        return new SoftMixingClip(this, (DataLine.Info) info);
    }

    throw new IllegalArgumentException("Line unsupported: " + info);
}
 
Example 8
Source File: AbstractMixer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether this is a target line for this mixer.
 * Right now this just checks whether it's supported, but should
 * check whether it actually belongs to this mixer....
 */
final boolean isTargetLine(Line.Info info) {

    for (int i = 0; i < targetLineInfo.length; i++) {
        if (info.matches(targetLineInfo[i])) {
            return true;
        }
    }

    return false;
}
 
Example 9
Source File: AbstractMixer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether this is a target line for this mixer.
 * Right now this just checks whether it's supported, but should
 * check whether it actually belongs to this mixer....
 */
final boolean isTargetLine(Line.Info info) {

    for (int i = 0; i < targetLineInfo.length; i++) {
        if (info.matches(targetLineInfo[i])) {
            return true;
        }
    }

    return false;
}
 
Example 10
Source File: Demo_MultichannelAudio_NativeMultipleSoundcard.java    From haxademic with MIT License 5 votes vote down vote up
protected Clip clipFromLine() {
	try {
		// did this even work??
		int lineIndex = UI.valueInt(LINE_INDEX);
		lineIndex = P.constrain(lineIndex, 0, linesOut.size() - 1);
		Line.Info lineInfo = linesOut.get(lineIndex);
    	Line line = AudioSystem.getLine(lineInfo);
        Clip clip = (Clip)line;

		return clip;
	} catch (LineUnavailableException e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 11
Source File: AbstractLine.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new AbstractLine.
 * @param mixer the mixer with which this line is associated
 * @param controls set of supported controls
 */
protected AbstractLine(Line.Info info, AbstractMixer mixer, Control[] controls) {

    if (controls == null) {
        controls = new Control[0];
    }

    this.info = info;
    this.mixer = mixer;
    this.controls = controls;
}
 
Example 12
Source File: SoftMixingMixer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Line getLine(Line.Info info) throws LineUnavailableException {

        if (!isLineSupported(info))
            throw new IllegalArgumentException("Line unsupported: " + info);

        if ((info.getLineClass() == SourceDataLine.class)) {
            return new SoftMixingSourceDataLine(this, (DataLine.Info) info);
        }
        if ((info.getLineClass() == Clip.class)) {
            return new SoftMixingClip(this, (DataLine.Info) info);
        }

        throw new IllegalArgumentException("Line unsupported: " + info);
    }
 
Example 13
Source File: AbstractMixer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether this is a target line for this mixer.
 * Right now this just checks whether it's supported, but should
 * check whether it actually belongs to this mixer....
 */
final boolean isTargetLine(Line.Info info) {

    for (int i = 0; i < targetLineInfo.length; i++) {
        if (info.matches(targetLineInfo[i])) {
            return true;
        }
    }

    return false;
}
 
Example 14
Source File: BogusMixers.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    try {
        out("4667064: Java Sound provides bogus SourceDataLine and TargetDataLine");

        Mixer.Info[]    aInfos = AudioSystem.getMixerInfo();
        out("  available Mixers:");
        for (int i = 0; i < aInfos.length; i++) {
            if (aInfos[i].getName().startsWith("Java Sound Audio Engine")) {
                Mixer mixer = AudioSystem.getMixer(aInfos[i]);
                Line.Info[] tlInfos = mixer.getTargetLineInfo();
                for (int ii = 0; ii<tlInfos.length; ii++) {
                    if (tlInfos[ii].getLineClass() == DataLine.class) {
                        throw new Exception("Bogus TargetDataLine with DataLine info present!");
                    }
                }
            }
            if (aInfos[i].getName().startsWith("WinOS,waveOut,multi threaded")) {
                throw new Exception("Bogus mixer 'WinOS,waveOut,multi threaded' present!");
            }
            out(aInfos[i].getName());
        }
        if (aInfos.length == 0)
        {
            out("[No mixers available] - not a failure of this test case.");
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
    out("Test passed");
}
 
Example 15
Source File: SoftMixingMixer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Line getLine(Line.Info info) throws LineUnavailableException {

        if (!isLineSupported(info))
            throw new IllegalArgumentException("Line unsupported: " + info);

        if ((info.getLineClass() == SourceDataLine.class)) {
            return new SoftMixingSourceDataLine(this, (DataLine.Info) info);
        }
        if ((info.getLineClass() == Clip.class)) {
            return new SoftMixingClip(this, (DataLine.Info) info);
        }

        throw new IllegalArgumentException("Line unsupported: " + info);
    }
 
Example 16
Source File: SoftMixingMixer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Line getLine(Line.Info info) throws LineUnavailableException {

        if (!isLineSupported(info))
            throw new IllegalArgumentException("Line unsupported: " + info);

        if ((info.getLineClass() == SourceDataLine.class)) {
            return new SoftMixingSourceDataLine(this, (DataLine.Info) info);
        }
        if ((info.getLineClass() == Clip.class)) {
            return new SoftMixingClip(this, (DataLine.Info) info);
        }

        throw new IllegalArgumentException("Line unsupported: " + info);
    }
 
Example 17
Source File: AbstractMixer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public final Line.Info[] getTargetLineInfo() {

        Line.Info[] localArray = new Line.Info[targetLineInfo.length];
        System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length);
        return localArray;
    }
 
Example 18
Source File: AbstractMixer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public abstract int getMaxLines(Line.Info info);
 
Example 19
Source File: AbstractLine.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public final Line.Info getLineInfo() {
    return info;
}
 
Example 20
Source File: AbstractMixer.java    From jdk8u_jdk with GNU General Public License v2.0 votes vote down vote up
public abstract Line getLine(Line.Info info) throws LineUnavailableException;