 (defn internal-booter [port]
   (reset! running?* true)
   (log/debug "booting internal audio server...")
-  (let [opts nil] ;; (sc-jna-startoptions-byref)
+  (let [opts (byref sc-jna-startoptions)] 
     (set! (. opts udp-port-num) port)
     (set! (. opts tcp-port-num) -1)
     (set! (. opts verbosity) 1)

         (log/debug "Booting SuperCollider internal server (scsynth)...")
         (.start sc-thread)
         (dosync (ref-set server-thread* sc-thread))
         (connect :internal)
         :booting))))

(defn- sc-log 

      (recur (inc cnt))))
   (register-notification-handlers))

(defn- connect-internal
  []
   (log/debug "Connecting to internal SuperCollider server")
   (let [dummy-obj []]
     (dosync (ref-set server* (with-meta
                                dummy-obj
                                {:type ::internal}))))
   (snd "/status")
   (dosync (ref-set status* :booted))
   ;;(register-notification-handlers)
   )

; TODO: setup an error-handler in the case that we can't connect to the server
(defn connect
  "Connect to an external SC audio server on the specified host and port."
  ([] (connect :external SERVER-HOST SERVER-PORT))
  ([which host port]
     (cond
      (= :internal which) (connect-internal)
      (= :external which) (.run (Thread. #(connect-thread-external host port))) )))

(defonce running?* (atom false))

