anchor.diff:  	(error 'unrecognized-file-format))
         (cond ((string-equal fourcc "avi ") (read-avi-header avi stream))
   	    (t (error 'unsupported-avi-file-format))))
  -    (bt:acquire-lock (vacancy-lock (car (wcursor (find-mjpeg-stream-record avi))))) ;the player shouldn't start before 1st frame is decoded
  +    (loop for rec in (stream-records avi) do
  +	 (bt:acquire-lock (vacancy-lock (car (wcursor rec))))) ;the player shouldn't start before 1st frame is decoded
       (when (player-callback avi)
         (funcall (player-callback avi) avi))
       (loop for chunk = (riff:read-riff-chunk stream :chunk-data-reader (chunk-decoder avi))
  -	 while chunk)))
  +	 while chunk)
  +    (loop for rec in (stream-records avi) do 
  +	 (setf (final rec) (car (wcursor rec)))
  +	 (bt:release-lock (vacancy-lock (car (wcursor rec)))))))
   
   (defun decode-file (pathname &key player-callback)
     (let ((avi-stream (make-instance 'avi-mjpeg-stream :filename pathname :player-callback player-callback)))
  
positive.code:   (flexi-streams:with-input-from-sequence (is +avi-dht+)
      (jpeg::read-dht (jpeg-descriptor rec) is))
    (setf (buffer rec) (make-array (suggested-buffer-size rec) :element-type '(unsigned-byte 8))
  	(chunk-queue rec) (make-list (* 2 (floor (rate rec) (scale rec)))))
    (loop for chunk on (chunk-queue rec) do
         (setf (car chunk) (make-instance 'chunk :frame (jpeg:allocate-buffer (height (avi rec)) (width (avi rec)) 3))))
    (setf (cdr (last (chunk-queue rec))) (chunk-queue rec)
  	(rcursor rec) (chunk-queue rec)
  	(wcursor rec) (chunk-queue rec)))
  
  (defclass audio-stream-record (stream-record)
    ())
  
negative.code: 					(make-array (suggested-buffer-size rec) :element-type '(unsigned-byte 8)))))
    (setf (cdr (last (chunk-queue rec))) (chunk-queue rec)
  	(rcursor rec) (chunk-queue rec)
  	(wcursor rec) (cdr (chunk-queue rec))))
  
  (defclass video-stream ()
    ((filename :accessor filename :initarg :filename :initform nil)))
  