Example usage for javax.sound.sampled LineUnavailableException LineUnavailableException

List of usage examples for javax.sound.sampled LineUnavailableException LineUnavailableException

Introduction

In this page you can find the example usage for javax.sound.sampled LineUnavailableException LineUnavailableException.

Prototype

public LineUnavailableException() 

Source Link

Document

Constructs a LineUnavailableException that has null as its error detail message.

Usage

From source file:com.amazon.alexa.avs.AVSController.java

private InputStream getMicrophoneInputStream(AVSController controller, RecordingRMSListener rmsListener)
        throws LineUnavailableException, IOException {

    int numberRetries = 1;

    if (this.wakeWordAgentEnabled) {
        numberRetries = WAKE_WORD_RELEASE_TRIES;
    }//from   ww  w  .ja  v  a2 s .co m

    for (; numberRetries > 0; numberRetries--) {
        try {
            return microphone.getAudioInputStream(controller, rmsListener);
        } catch (LineUnavailableException | IOException e) {
            if (numberRetries == 1) {
                throw e;
            }
            log.warn("Could not open the microphone line.");
            try {
                Thread.sleep(WAKE_WORD_RELEASE_RETRY_DELAY_MS);
            } catch (InterruptedException e1) {
                log.error("exception:", e1);
            }
        }
    }

    throw new LineUnavailableException();
}