Path: blob/master/test/jdk/javax/sound/sampled/Mixers/NoSimpleInputDevice.java
41153 views
/*1* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import javax.sound.sampled.AudioSystem;24import javax.sound.sampled.Mixer;2526/**27* @test28* @bug 493639729* @summary Verify that there'll be either SimpleInputDevice OR DirectAudioDevice30*/31public class NoSimpleInputDevice {3233public static void main(String[] args) throws Exception {34out("4936397: Verify that there'll be either SimpleInputDevice OR DirectAudioDevice");35boolean foundSimpleInputDevice = false;36boolean foundDirectAudioDevice = false;3738Mixer.Info[] aInfos = AudioSystem.getMixerInfo();39for (int i = 0; i < aInfos.length; i++) {40try {41Mixer mixer = AudioSystem.getMixer(aInfos[i]);42String mixerClass = mixer.getClass().toString();43if (mixerClass.indexOf("SimpleInputDevice") >= 0) {44out("Found SimpleInputDevice: "+aInfos[i]);45foundSimpleInputDevice = true;46}47if (mixerClass.indexOf("DirectAudioDevice") >= 0) {48out("Found DirectAudioDevice: "+aInfos[i]);49foundDirectAudioDevice = true;50}51} catch (Exception e) {52out("Unexpected exception: "+e);53}54}55if (aInfos.length == 0) {56out("[No mixers available] - cannot exercise this test.");57} else {58if (foundSimpleInputDevice && foundDirectAudioDevice) {59out("Found both types of capture devices!");60throw new Exception("Test FAILED!");61}62out("Did not find both types of capture devices. Test passed");63}64}6566static void out(String s) {67System.out.println(s); System.out.flush();68}69}707172