Esempio n. 1
0
 public void close() throws IOException {
   if (line.isActive()) {
     line.flush();
     line.stop();
   }
   line.close();
 }
Esempio n. 2
0
  public void deactivate() {
    active = false;
    microphone.stop();
    microphone.flush();

    speaker.stop();
    speaker.flush();
  }
Esempio n. 3
0
 public void run() {
   try {
     b = new byte[6300];
     line.open(new AudioFormat(44100, 16, 1, true, true), 6300);
     line.start();
     while (true) {
       line.read(b, 0, b.length);
       server.writeByteBuffers(b, sourceIndex);
       if (output) serverOutput.write(b, 0, b.length);
     }
   } catch (LineUnavailableException e) {
     e.printStackTrace();
     System.out.println(sourceIndex);
   } finally {
     line.stop();
     line.close();
   }
 }
Esempio n. 4
0
 /**
  * Stops the recording.
  *
  * <p>Note that stopping the thread explicitely is not necessary. Once no more data can be read
  * from the TargetDataLine, no more data be read from our AudioInputStream. And if there is no
  * more data from the AudioInputStream, the method 'AudioSystem.write()' (called in 'run()'
  * returns. Returning from 'AudioSystem.write()' is followed by returning from 'run()', and thus,
  * the thread is terminated automatically.
  *
  * <p>It's not a good idea to call this method just 'stop()' because stop() is a (deprecated)
  * method of the class 'Thread'. And we don't want to override this method.
  */
 public void stopRecording() {
   m_line.stop();
   m_line.close();
 }
Esempio n. 5
0
 public void stopMic() {
   microphone.stop();
 }