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"); } }
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(); }