           (throw-exception (str (- (System/currentTimeMillis) start-time)
                                 " Timed out waiting for image\nto arrive from camera."))
           (do (when (core isBufferOverflowed)
+                (println "Circular buffer overflowed")
                 (throw-exception "Circular buffer overflowed."))
               (Thread/sleep 1)
               (recur)))))))

    {:pix (.pix tagged-image)
     :tags (json-to-data (.tags tagged-image))}))

(defn pop-burst-images
  [n timeout-ms]
  (let [queue (proxy [LinkedBlockingQueue] [10]
                (take [] (let [item (proxy-super take)]
                           (if (instance? Throwable item)
                             (throw item)
                             item))))]
    (future
      (dotimes [i n]
        (try (.put queue (pop-burst-image timeout-ms))
             (catch Throwable t (.put queue t)))))
      queue))

(defn make-multicamera-channel [raw-channel-index camera-channel num-camera-channels]
  (+ camera-channel (* num-camera-channels (or raw-channel-index 0))))

      (catch Exception e (log "wait for device" dev "failed.")))))

(defn set-exposure [camera exp]
  (when (not= exp (get-in @state [:cameras camera :exposure]))
    (device-best-effort camera (core setExposure exp))
    (swap! state assoc-in [:cameras camera :exposure] exp)))

(defn wait-for-pending-devices []
  (log "pending devices: " @pending-devices)
