java类javax.sound.sampled.LineUnavailableException的实例源码

StdAudio.java 文件源码 项目:MusicToGraph 阅读 23 收藏 0 点赞 0 评论 0
private static void init() {
    try {
        // 44,100 samples per second, 16-bit audio, mono, signed PCM, little
        // Endian
        AudioFormat format = new AudioFormat((float) SAMPLE_RATE, BITS_PER_SAMPLE, 1, true, false);
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);

        line = (SourceDataLine) AudioSystem.getLine(info);
        line.open(format, SAMPLE_BUFFER_SIZE * BYTES_PER_SAMPLE);

        // the internal buffer is a fraction of the actual buffer size, this
        // choice is arbitrary
        // it gets divided because we can't expect the buffered data to line
        // up exactly with when
        // the sound card decides to push out its samples.
        buffer = new byte[SAMPLE_BUFFER_SIZE * BYTES_PER_SAMPLE / 3];
    } catch (LineUnavailableException e) {
        System.out.println(e.getMessage());
    }

    // no sound gets made before this call
    line.start();
}
GSpeechDuplex.java 文件源码 项目:java-google-speech-api 阅读 15 收藏 0 点赞 0 评论 0
/**
 * Streams data from the TargetDataLine to the API.
 * 
 * @param urlStr
 *            The URL to stream to
 * @param tl
 *            The target data line to stream from.
 * @param af
 *            The AudioFormat to stream with.`
 * @throws LineUnavailableException
 *             If cannot open or stream the TargetDataLine.
 */
private Thread upChannel(String urlStr , TargetDataLine tl , AudioFormat af) throws LineUnavailableException {
    final String murl = urlStr;
    final TargetDataLine mtl = tl;
    final AudioFormat maf = af;
    if (!mtl.isOpen()) {
        mtl.open(maf);
        mtl.start();
    }
    Thread upChannelThread = new Thread("Upstream Thread") {
        public void run() {
            openHttpsPostConnection(murl, mtl, (int) maf.getSampleRate());
        }
    };
    upChannelThread.start();
    return upChannelThread;

}
AudioSystemSoundOutput.java 文件源码 项目:coffee-gb 阅读 16 收藏 0 点赞 0 评论 0
@Override
public void start() {
    if (line != null) {
        LOG.debug("Sound already started");
        return;
    }
    LOG.debug("Start sound");
    try {
        line = AudioSystem.getSourceDataLine(FORMAT);
        line.open(FORMAT, BUFFER_SIZE);
    } catch (LineUnavailableException e) {
        throw new RuntimeException(e);
    }
    line.start();
    buffer = new byte[line.getBufferSize()];
    divider = (int) (Gameboy.TICKS_PER_SEC / FORMAT.getSampleRate());
}
Replay.java 文件源码 项目:rcom 阅读 18 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws IOException, LineUnavailableException {
    File folder=new File("/home/rizsi/tmp/video");
    byte[] data=UtilFile.loadFile(new File(folder, "remote.sw"));
    byte[] data2=UtilFile.loadFile(new File(folder, "local.sw"));
    System.out.println("remote.sw max: "+measureMax(data));
    System.out.println("local.sw max: "+measureMax(data2));
    byte[] data3=sum(data, data2);
    UtilFile.saveAsFile(new File(folder, "rawmic.sw"), data3);
    AudioFormat format=ManualTestEchoCancel.getFormat();
    final Mixer mixer = AudioSystem.getMixer(null);
    Play p=new Play(mixer, format, ManualTestEchoCancel.frameSamples)
    {
        @Override
        protected void switchBuffer() {
            if(getSample()==data)
            {
                setSample(data2);
            }else if(getSample()==data2)
            {
                setSample(data3);
            }
        }
    };
    p.start();
    p.setSample(data);
}
SoundGenerator.java 文件源码 项目:Explorium 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Play a sound at a given frequency freq during duration (in seconds) with volume as strenght
 * <br/><br/>
 * <code>SoundGenerator.playSound(440.0,1.0,0.5,SoundGenerator.FADE_LINEAR,SoundGenerator.WAVE_SIN);</code><br/>
 * Available fades : FADE_NONE, FADE_LINEAR, FADE_QUADRATIC<br/>
 * Available waves : WAVE_SIN, WAVE_SQUARE, WAVE_TRIANGLE, WAVE_SAWTOOTH<br/>
 */
public static void playSound(double freq,double duration,double volume,byte fade,byte wave){

    double[] soundData = generateSoundData(freq,duration,volume,fade,wave);
    byte[] freqdata = new byte[soundData.length];

    for(int i = 0;i < soundData.length;i++) {
        freqdata[i] = (byte)soundData[i];
    }

    // Play it
    try {
        final AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, true);
        SourceDataLine line = AudioSystem.getSourceDataLine(af);
        line.open(af, SAMPLE_RATE);
        line.start();
        line.write(freqdata, 0, freqdata.length);
        line.drain();
        line.close();
    }catch(LineUnavailableException e) {
        e.printStackTrace();
    }
}
AudioInterface.java 文件源码 项目:BassNES 阅读 18 收藏 0 点赞 0 评论 0
public void restartSDL(){
    AudioFormat form = new AudioFormat(sys.getSampleRate(),16,2,true,false);

    bufptr=0;
    audioints = new int[(int)((sys.getSampleRate()/1000.0)*sys.getBufferSize())*2];
    if(scope!=null)
        scope.setAudio(audioints);
    audiobuffer = new byte[audioints.length*2];
    try {
        if(sdl!=null)
            sdl.close();
        sdl = AudioSystem.getSourceDataLine(form);
        sdl.open(form,audiobuffer.length*3);
        sdl.start();
    } catch (LineUnavailableException e) {
        e.printStackTrace();
    }

}
VirtualDrummerMicrophoneInput.java 文件源码 项目:jaer 阅读 21 收藏 0 点赞 0 评论 0
/** Creates a new instance of test. Opens the microphone input as the target line.
     * To start the reporting, {@link #start} the thread.
     * @throws LineUnavailableException if microphone input is not available
     */
    public VirtualDrummerMicrophoneInput () throws LineUnavailableException{
//        getAudioInfo();  // prints lots of useless information
        format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,sampleRate,8,1,1,sampleRate,false);

        DataLine.Info dlinfo = new DataLine.Info(TargetDataLine.class,
                format);
        if ( AudioSystem.isLineSupported(dlinfo) ){
            targetDataLine = (TargetDataLine)AudioSystem.getLine(dlinfo);
        }
        targetDataLine.open(format,bufferSize);
        bufferSize=targetDataLine.getBufferSize();
        gui = new DrumSoundDetectorDemo();
        gui.setVirtualDrummerMicrophoneInput(this);

    }
EnemySniper.java 文件源码 项目:What-Happened-to-Station-7 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Picks a player to attack
 */
public void attack()
{
    Player weakest = null;

    for (Entity e : getLevel().getEntities())
        if (e.isActive() && e instanceof Player)
            if (!getLevel().isThroughWall(getLocation(), e.getLocation()))
            {
                Player p = (Player) e;
                if (weakest == null || p.getHealth() < weakest.getHealth())
                    weakest = p;
            }

    weakest.takeDamage(75);

    try
    {
        SoundStuff cam = new SoundStuff();
        cam.AWP();
    }
    catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1)
    {
        e1.printStackTrace();
    }
}
AudioClip.java 文件源码 项目:Mafia 阅读 21 收藏 0 点赞 0 评论 0
private void loadClip() {
    try {
        clip = AudioSystem.getClip();

        InputStream in = getClass().getClassLoader().getResourceAsStream(filePath);
        BufferedInputStream bufferedIn = new BufferedInputStream(in);
        AudioInputStream audioIn = AudioSystem.getAudioInputStream(bufferedIn);

        clip.open(audioIn);


        volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    } catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
PortMixer.java 文件源码 项目:OpenJSharp 阅读 23 收藏 0 点赞 0 评论 0
void implOpen() throws LineUnavailableException {
    if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
    long newID = ((PortMixer) mixer).getID();
    if ((id == 0) || (newID != id) || (controls.length == 0)) {
        id = newID;
        Vector vector = new Vector();
        synchronized (vector) {
            nGetControls(id, portIndex, vector);
            controls = new Control[vector.size()];
            for (int i = 0; i < controls.length; i++) {
                controls[i] = (Control) vector.elementAt(i);
            }
        }
    } else {
        enableControls(controls, true);
    }
    if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded");
}
PortMixer.java 文件源码 项目:OpenJSharp 阅读 22 收藏 0 点赞 0 评论 0
public void open() throws LineUnavailableException {
    synchronized (mixer) {
        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            if (Printer.trace) Printer.trace("> PortMixerPort: open");
            // reserve mixer resources for this line
            mixer.open(this);
            try {
                // open the line.  may throw LineUnavailableException.
                implOpen();

                // if we succeeded, set the open state to true and send events
                setOpen(true);
            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
            if (Printer.trace) Printer.trace("< PortMixerPort: open succeeded");
        }
    }
}
VoiceR.java 文件源码 项目:duncan 阅读 18 收藏 0 点赞 0 评论 0
public void run () {
    //create a separate thread for recording
    Thread recordThread = new Thread(new Runnable() {
         @Override
         public void run() {
             try {
                 System.out.println("Start recording...");
                 recorder.start();
             } catch (LineUnavailableException ex) {
                 ex.printStackTrace();
                 System.exit(-1);
             }
         }
     });
     recordThread.start();
    //  try {
    //      Thread.sleep(RECORD_TIME);
    //  } catch (InterruptedException ex) {
    //      ex.printStackTrace();
    //  }
}
PortMixer.java 文件源码 项目:jdk8u-jdk 阅读 17 收藏 0 点赞 0 评论 0
void implOpen() throws LineUnavailableException {
    if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
    long newID = ((PortMixer) mixer).getID();
    if ((id == 0) || (newID != id) || (controls.length == 0)) {
        id = newID;
        Vector vector = new Vector();
        synchronized (vector) {
            nGetControls(id, portIndex, vector);
            controls = new Control[vector.size()];
            for (int i = 0; i < controls.length; i++) {
                controls[i] = (Control) vector.elementAt(i);
            }
        }
    } else {
        enableControls(controls, true);
    }
    if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded");
}
PortMixer.java 文件源码 项目:jdk8u-jdk 阅读 24 收藏 0 点赞 0 评论 0
public void open() throws LineUnavailableException {
    synchronized (mixer) {
        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            if (Printer.trace) Printer.trace("> PortMixerPort: open");
            // reserve mixer resources for this line
            mixer.open(this);
            try {
                // open the line.  may throw LineUnavailableException.
                implOpen();

                // if we succeeded, set the open state to true and send events
                setOpen(true);
            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
            if (Printer.trace) Printer.trace("< PortMixerPort: open succeeded");
        }
    }
}
DataLine_ArrayIndexOutOfBounds.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
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");
    }
}
SoftMixingMixer.java 文件源码 项目:openjdk-jdk10 阅读 26 收藏 0 点赞 0 评论 0
@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);
}
GSpeechDuplex.java 文件源码 项目:java-google-speech-api 阅读 15 收藏 0 点赞 0 评论 0
/**
 * This method allows you to stream a continuous stream of data to the API.
 * <p>
 * Note: This feature is experimental.
 * </p>
 * 
 * @param tl
 *            TL
 * @param af
 *            AF
 * @throws LineUnavailableException
 *             If the Line is unavailable
 * @throws InterruptedException
 *             InterruptedException
 */
public void recognize(TargetDataLine tl , AudioFormat af) throws LineUnavailableException , InterruptedException {
    //Generates a unique ID for the response. 
    final long PAIR = MIN + (long) ( Math.random() * ( ( MAX - MIN ) + 1L ) );

    //Generates the Downstream URL
    final String API_DOWN_URL = GOOGLE_DUPLEX_SPEECH_BASE + "down?maxresults=1&pair=" + PAIR;

    //Generates the Upstream URL
    final String API_UP_URL = GOOGLE_DUPLEX_SPEECH_BASE + "up?lang=" + language + "&lm=dictation&client=chromium&pair=" + PAIR + "&key=" + API_KEY
            + "&continuous=true&interim=true"; //Tells Google to constantly monitor the stream;

    //Opens downChannel
    Thread downChannel = this.downChannel(API_DOWN_URL);

    //Opens upChannel
    Thread upChannel = this.upChannel(API_UP_URL, tl, af);
    try {
        downChannel.join();
        upChannel.interrupt();
        upChannel.join();
    } catch (InterruptedException e) {
        downChannel.interrupt();
        downChannel.join();
        upChannel.interrupt();
        upChannel.join();
    }

}
Audio.java 文件源码 项目:lembredio 阅读 27 收藏 0 点赞 0 评论 0
public void playAudio(int tempo, boolean flag) throws UnsupportedAudioFileException, LineUnavailableException, IOException, InterruptedException{
    Clip clip = AudioSystem.getClip();
    URL url = getClass().getResource("/audio/smb_die.wav");
    URL urlToHot = this.getClass().getResource("/audio/smb_die.wav");
    System.out.println(urlToHot);
    this.audio = Applet.newAudioClip(url);
    if(flag) audio.loop();
    else audio.stop();

}
PacienteInterface.java 文件源码 项目:lembredio 阅读 20 收藏 0 点赞 0 评论 0
public PacienteInterface(String nome) throws FileNotFoundException, IOException, UnsupportedAudioFileException, LineUnavailableException, InterruptedException{

   initComponents();
   nomeUser = nome;
   jLabel2NP.setText(nome);
   setVisible(true);
   initXYK();
   updateRemedy(false);
   compareHour();
}
Sound.java 文件源码 项目:Lunar 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Play the audio.
 */
public void play() {
    try {
        if (!isLoaded()) {
            load();
        }
        clip.start();
    } catch (IOException | LineUnavailableException | UnsupportedAudioFileException e) {
        System.out.println("ERROR PLAYING SOUND. /n");
        e.printStackTrace();
        this.stop();
    }
}
AlarmNotifier.java 文件源码 项目:neoscada 阅读 21 收藏 0 点赞 0 评论 0
private void enableHorn () throws UnsupportedAudioFileException, IOException, LineUnavailableException
{
    if ( ( this.clip == null || !this.clip.isRunning () ) && Activator.getDefault ().getPreferenceStore ().getBoolean ( PreferenceConstants.BELL_ACTIVATED_KEY ) )
    {
        final AudioInputStream sound = AudioSystem.getAudioInputStream ( this.soundFile );
        final DataLine.Info info = new DataLine.Info ( Clip.class, sound.getFormat () );
        this.clip = (Clip)AudioSystem.getLine ( info );
        this.clip.open ( sound );
        this.clip.loop ( Clip.LOOP_CONTINUOUSLY );
    }
    if ( !this.bellIcon.isDisposed () )
    {
        this.bellIcon.setImage ( getBellIcon () );
    }
}
Play.java 文件源码 项目:Panako 阅读 30 收藏 0 点赞 0 评论 0
@Override
public void run(String... args) {
    String inputResource = AudioResourceUtils.sanitizeResource(args[0]);
    AudioDispatcher d;
    try {
        d = AudioDispatcherFactory.fromPipe(inputResource, TARGET_SAMPLE_RATE, 2028, 0);
        d.addAudioProcessor(new AudioPlayer(JVMAudioInputStream.toAudioFormat(d.getFormat())));
        d.run();
    }  catch (LineUnavailableException e) {
        e.printStackTrace();
        System.err.print(e.getLocalizedMessage());
    }
}
RafsRepStrategy.java 文件源码 项目:Panako 阅读 18 收藏 0 点赞 0 评论 0
@Override
public void monitor(String query, int maxNumberOfReqults, Set<Integer> avoid, QueryResultHandler handler) {
    int samplerate = Config.getInt(Key.RAFS_SAMPLE_RATE);
    int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
    int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
    AudioDispatcher d ;
    if (query.equals(Panako.DEFAULT_MICROPHONE)){
        try {
            d = AudioDispatcherFactory.fromDefaultMicrophone(samplerate,size, overlap);
        } catch (LineUnavailableException e) {
            LOG.warning("Could not connect to default microphone!" + e.getMessage());
            e.printStackTrace();
            d = null;
        }
    }else{
        d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
    }
    d.setZeroPadFirstBuffer(true);
    d.addAudioProcessor(new AudioProcessor() {
        @Override
        public boolean process(AudioEvent audioEvent) {
            double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
            processMonitorQuery(audioEvent.getFloatBuffer().clone(), handler,timeStamp,avoid);
            return true;
        }

        @Override
        public void processingFinished() {
        }
    });
    d.run();
}
NFFTStrategy.java 文件源码 项目:Panako 阅读 21 收藏 0 点赞 0 评论 0
public void monitor(String query,final SerializedFingerprintsHandler handler){

    int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
    int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
    int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
    AudioDispatcher d ;
    if (query.equals(Panako.DEFAULT_MICROPHONE)){
        try {
            d = AudioDispatcherFactory.fromDefaultMicrophone(samplerate,size, overlap);
        } catch (LineUnavailableException e) {
            LOG.warning("Could not connect to default microphone!" + e.getMessage());
            e.printStackTrace();
            d = null;
        }
    }else{
        d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
    }
    d.addAudioProcessor(new AudioProcessor() {
        @Override
        public boolean process(AudioEvent audioEvent) {
            double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
            processMonitorQueryToSerializeFingerprints(audioEvent.getFloatBuffer().clone(), handler,timeStamp);
            return true;
        }

        @Override
        public void processingFinished() {
        }
    });
    d.run();
}
NFFTStrategy.java 文件源码 项目:Panako 阅读 16 收藏 0 点赞 0 评论 0
@Override
public void monitor(String query,final  int maxNumberOfResults,Set<Integer> avoid,
        final QueryResultHandler handler) {

    int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
    int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
    int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
    AudioDispatcher d ;
    if (query.equals(Panako.DEFAULT_MICROPHONE)){
        try {
            d = AudioDispatcherFactory.fromDefaultMicrophone(samplerate,size, overlap);
        } catch (LineUnavailableException e) {
            LOG.warning("Could not connect to default microphone!" + e.getMessage());
            e.printStackTrace();
            d = null;
        }
    }else{
        d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
    }
    d.addAudioProcessor(new AudioProcessor() {
        @Override
        public boolean process(AudioEvent audioEvent) {
            double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
            processMonitorQuery(audioEvent.getFloatBuffer().clone(), maxNumberOfResults, handler,timeStamp,avoid);
            return true;
        }

        @Override
        public void processingFinished() {
        }
    });
    d.run();
}
Microphone.java 文件源码 项目:BrainControl 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Opens the audio capturing device so that it will be ready for capturing
 * audio. Attempts to create a converter if the requested audio format is
 * not directly available.
 *
 * @return true if the audio capturing device is opened successfully; false
 *         otherwise
 */
private boolean open() {
    TargetDataLine audioLine = getAudioLine();
    if (audioLine != null) {
        if (!audioLine.isOpen()) {
            logger.info("open");
            try {
                audioLine.open(finalFormat, audioBufferSize);
            } catch (LineUnavailableException e) {
                logger.severe("Can't open microphone " + e.getMessage());
                return false;
            }

            audioStream = new AudioInputStream(audioLine);
            if (doConversion) {
                audioStream = AudioSystem.getAudioInputStream(desiredFormat, audioStream);
                assert (audioStream != null);
            }

            /*
             * Set the frame size depending on the sample rate.
             */
            float sec = ((float) msecPerRead) / 1000.f;
            frameSizeInBytes = (audioStream.getFormat().getSampleSizeInBits() / 8)
                    * (int) (sec * audioStream.getFormat().getSampleRate());

            logger.info("Frame size: " + frameSizeInBytes + " bytes");
        }
        return true;
    } else {
        logger.severe("Can't find microphone");
        return false;
    }
}
Sound.java 文件源码 项目:Explorium 阅读 27 收藏 0 点赞 0 评论 0
public Sound(String file){
    try {
        ais = AudioSystem.getAudioInputStream(new File(file));
        clip = AudioSystem.getClip();
        clip.open(ais);
    } catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
        e.printStackTrace();
    }
}
MainController.java 文件源码 项目:KenzieTheBot 阅读 28 收藏 0 点赞 0 评论 0
private void startSpeechRecognition() {

        new Thread(
                () -> {
                    try {

                        gSpeechDuplex.recognize(mic.getTargetDataLine(), mic.getAudioFormat());

                    } catch (InterruptedException | LineUnavailableException exception) {

                        System.out.println("Exception caused : " + exception.getMessage());
                    }
                }).start();
    }
UnexpectedIAE.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
public static void main(String argv[]) throws Exception {
    boolean success = true;

    Mixer.Info [] infos = AudioSystem.getMixerInfo();

    for (int i=0; i<infos.length; i++) {
        Mixer mixer = AudioSystem.getMixer(infos[i]);
        System.out.println("Mixer is: " + mixer);
        Line.Info [] target_line_infos = mixer.getTargetLineInfo();
        for (int j = 0; j < target_line_infos.length; j++) {
            try {
                System.out.println("Trying to get:" + target_line_infos[j]);
                mixer.getLine(target_line_infos[j]);
            } catch (IllegalArgumentException iae) {
                System.out.println("Unexpected IllegalArgumentException raised:");
                iae.printStackTrace();
                success = false;
            } catch (LineUnavailableException lue) {
                System.out.println("Unexpected LineUnavailableException raised:");
                lue.printStackTrace();
                success = false;
            }
        }
    }
    if (success) {
        System.out.println("Test passed");
    } else {
        throw new Exception("Test FAILED");
    }
}
SoftMixingClip.java 文件源码 项目:openjdk-jdk10 阅读 18 收藏 0 点赞 0 评论 0
@Override
public void open() throws LineUnavailableException {
    if (data == null) {
        throw new IllegalArgumentException(
                "Illegal call to open() in interface Clip");
    }
    open(format, data, offset, bufferSize);
}


问题


面经


文章

微信
公众号

扫码关注公众号