Java Code Examples for javax.sound.sampled.Mixer#close()

The following examples show how to use javax.sound.sampled.Mixer#close() . 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: DataLine_ArrayIndexOutOfBounds.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 2
Source File: DataLine_ArrayIndexOutOfBounds.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 3
Source File: DataLine_ArrayIndexOutOfBounds.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 4
Source File: DataLine_ArrayIndexOutOfBounds.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 5
Source File: DataLine_ArrayIndexOutOfBounds.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 6
Source File: DataLine_ArrayIndexOutOfBounds.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 7
Source File: DataLine_ArrayIndexOutOfBounds.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 8
Source File: DataLine_ArrayIndexOutOfBounds.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 9
Source File: DataLine_ArrayIndexOutOfBounds.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 10
Source File: DataLine_ArrayIndexOutOfBounds.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 11
Source File: DataLine_ArrayIndexOutOfBounds.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 12
Source File: DataLine_ArrayIndexOutOfBounds.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 13
Source File: DataLine_ArrayIndexOutOfBounds.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Mixer.Info[] infos = AudioSystem.getMixerInfo();
    log("" + infos.length + " mixers detected");
    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        log("Mixer " + (i+1) + ": " + infos[i]);
        try {
            mixer.open();
            for (Scenario scenario: scenarios) {
                testSDL(mixer, scenario);
                testTDL(mixer, scenario);
            }
            mixer.close();
        } catch (LineUnavailableException ex) {
            log("LineUnavailableException: " + ex);
        }
    }
    if (failed == 0) {
        log("PASSED (" + total + " tests)");
    } else {
        log("FAILED (" + failed + " of " + total + " tests)");
        throw new Exception("Test FAILED");
    }
}
 
Example 14
Source File: JavaInfo.java    From haxademic with MIT License 4 votes vote down vote up
public static void printAudioInfo() {
		P.out("----------------- printAudioInfo -------------------");
		Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
		for(int i = 0; i < mixerInfo.length; i++) {
			P.out("########## mixerInfo["+i+"]", mixerInfo[i].getName());

//			Mixer mixer = AudioSystem.getMixer(null); // default mixer
			Mixer mixer = AudioSystem.getMixer(mixerInfo[i]); // default mixer
			try {
				mixer.open();
			} catch (LineUnavailableException e) {
				e.printStackTrace();
			}
	
			P.out("Supported SourceDataLines of default mixer (%s):\n\n", mixer.getMixerInfo().getName());
			for(Line.Info info : mixer.getSourceLineInfo()) {
			    if(SourceDataLine.class.isAssignableFrom(info.getLineClass())) {
			        SourceDataLine.Info info2 = (SourceDataLine.Info) info;
			        P.out(info2);
			        System.out.printf("  max buffer size: \t%d\n", info2.getMaxBufferSize());
			        System.out.printf("  min buffer size: \t%d\n", info2.getMinBufferSize());
			        AudioFormat[] formats = info2.getFormats();
			        P.out("  Supported Audio formats: ");
			        for(AudioFormat format : formats) {
			        	P.out("    "+format);
			          System.out.printf("      encoding:           %s\n", format.getEncoding());
			          System.out.printf("      channels:           %d\n", format.getChannels());
			          System.out.printf(format.getFrameRate()==-1?"":"      frame rate [1/s]:   %s\n", format.getFrameRate());
			          System.out.printf("      frame size [bytes]: %d\n", format.getFrameSize());
			          System.out.printf(format.getSampleRate()==-1?"":"      sample rate [1/s]:  %s\n", format.getSampleRate());
			          System.out.printf("      sample size [bit]:  %d\n", format.getSampleSizeInBits());
			          System.out.printf("      big endian:         %b\n", format.isBigEndian());
			          
			          Map<String,Object> prop = format.properties();
			          if(!prop.isEmpty()) {
			        	  P.out("      Properties: ");
			              for(Map.Entry<String, Object> entry : prop.entrySet()) {
			                  System.out.printf("      %s: \t%s\n", entry.getKey(), entry.getValue());
			              }
			          }
			        }
			        P.out();
			    } else {
			    	P.out(info.toString());
			    }
			    P.out();
			}
			mixer.close();
		}
	}