public synchronized void waitFor() { if (!terminated) { try { this.join(); } catch (InterruptedException ie) { if (DEBUG) ie.printStackTrace(); } } }
public void run() { byte[] buffer = new byte[getBufferSize()]; if (VERBOSE) out("Start AudioCapture push thread"); try { AudioInputStream localAIS = ais; while (!doTerminate) { out("Capture running"); if (localAIS != null) { int r = localAIS.read(buffer, 0, buffer.length); if (r > 0) { synchronized (AudioCapture.this) { if (outputStream != null) { outputStream.write(buffer, 0, r); out("Recorded " + r + " Bytes"); // _fireAudioCapturedEvent(); } } if (outputStream == null) { synchronized (this) { this.wait(100); } } } else { if (r == 0) { synchronized (this) { this.wait(20); } } } } else { synchronized (this) { this.wait(50); } } } } catch (IOException ioe) { // if (VERBOSE) ioe.printStackTrace(); } catch (InterruptedException ie) { if (DEBUG) ie.printStackTrace(); } terminated = true; if (VERBOSE) out("Stop AudioCapture push thread"); }