Ejemplo n.º 1
0
 protected void closeLine(boolean willReopen) {
   CaptureThread oldThread = null;
   synchronized (this) {
     if (!willReopen && thread != null) {
       thread.terminate();
     }
     super.closeLine(willReopen);
     if (!willReopen) {
       if (ais != null) {
         if (VERBOSE) out("AudioCapture.closeLine(): closing input stream");
         try {
           ais.close();
         } catch (IOException ignored) {
         }
       }
       if (thread != null) {
         if (outputStream != null) {
           try {
             outputStream.close();
           } catch (IOException ignored) {
           }
           outputStream = null;
         }
         oldThread = thread;
       }
     }
   }
   if (oldThread != null) {
     if (VERBOSE) out("AudioCapture.closeLine(): closing thread, waiting for it to die");
     oldThread.waitFor();
     if (VERBOSE) out("AudioCapture.closeLine(): thread closed");
   }
 }
Ejemplo n.º 2
0
 public synchronized void start() throws Exception {
   boolean needStartThread = false;
   if (thread != null && (thread.isTerminating() || outputStream == null)) {
     thread.terminate();
     needStartThread = true;
   }
   if (VERBOSE) out("AudioCapture: start with OutputStream = " + outputStream);
   if ((thread == null || needStartThread) && outputStream != null) {
     // start thread
     thread = new CaptureThread();
     thread.start();
   }
   super.start();
 }
Ejemplo n.º 3
0
 /**
  * Set the output stream to write to. Must be set *before* calling start. When writing to the
  * Output Stream, the stream returned by getAudioInputStream must not be read from.
  */
 public synchronized void setOutputStream(OutputStream stream) {
   this.outputStream = stream;
   // Debug.out("AudioCapture.setOutputStream(): output stream: " +
   // this.outputStream);
   if (this.outputStream == null && thread != null) {
     thread.terminate();
     thread = null;
   }
 }