@Override public void run() { while (!stopped) { synchronized (this) { if (updateRequired_0) { if (frequency_0 == 0) { clip0.stop(); } else { playFrequency(clip0, frequency_0); } updateRequired_0 = false; } } synchronized (this) { if (updateRequired_1) { if (frequency_1 == 0) { clip1.stop(); } else { playFrequency(clip1, frequency_1); } updateRequired_1 = false; } } try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } }
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"); }