anchor.diff:  ;;; A very basic Advanced Linux Sound Architecture interface
   
   (in-package #:also-alsa)
  +
  +(eval-when (:compile-toplevel)
  +  (defconstant +epipe+ 32))
   
   (define-foreign-library libasound
     (:unix "libasound.so.2")
  
positive.code:     (ensure-success (snd-pcm-hw-params-set-rate (deref (handle pcs)) (deref (params pcs)) (sample-rate pcs) 0))
      (ensure-success (snd-pcm-hw-params-set-channels (deref (handle pcs)) (deref (params pcs)) (channels-count pcs)))
      (ensure-success (snd-pcm-hw-params (deref (handle pcs)) (deref (params pcs))))
      (snd-pcm-hw-params-free (deref (params pcs)))
      (ensure-success (snd-pcm-prepare (deref (handle pcs))))
  
      (ensure-success (snd-pcm-sw-params-malloc (swparams pcs)))
      (ensure-success (snd-pcm-sw-params-current (deref (handle pcs)) (deref (swparams pcs))))
      (when start-threshold
  
negative.code:   (assert (eql (direction pcm) :snd-pcm-stream-playback))
    (let ((result (snd-pcm-writei (deref (handle pcm)) (buffer pcm) (buffer-size pcm))))
      (unless (= result (buffer-size pcm))
        (if (eql result (- +epipe+))
  	  (progn (format t "Underrun!") (snd-pcm-prepare (deref (handle pcm))))
  	  (error "ALSA error: ~A" result)))))
  
  (defmethod alsa-read ((pcm pcm-stream))
    (assert (eql (direction pcm) :snd-pcm-stream-capture))
    (let ((result (snd-pcm-readi (deref (handle pcm)) (buffer pcm) (buffer-size pcm))))
      (unless (= result (buffer-size pcm))
        (if (eql result (- +epipe+))
  	  (progn (format t "Underrun!") (snd-pcm-prepare (deref (handle pcm))))
  	  (error "ALSA error: ~A" result)))
      pcm))
  
  (defmethod contents-to-lisp ((pcm pcm-stream))
  