public void stop() throws CaptureException {
    if (!started) return;

    stopping = true;

    if (thread != null) thread.close();

    if (thread != null) {
      try {
        logger.fine("Waiting for GrabberThread to complete...");
        thread.waitUntilClosed();
      } catch (InterruptedException e) {
        logger.log(Level.WARNING, "" + e, e);
        return;
      }
    }
    logger.fine("GrabberThread completed");
    thread = null;

    try {
      disposeSequenceGrabber();
    } catch (QTException e) {
      throw new CaptureException(e);
    }

    started = false;
    stopping = false;
  }
  public void start() throws CaptureException {
    if (started) return;

    if (thread != null) {
      logger.log(
          Level.WARNING, "QTCaptureStream already started, start called without stop, ignoring");
      return;
    }
    try {

      initSequenceGrabber();

      initBufferedImage();

      startPreviewing();

    } catch (QTException e) {
      throw new CaptureException(e);
    }
    if (thread == null) {
      thread = new GrabberThread();
      thread.start();
    }
    started = true;
  }