Better flac error handling and reporting
This commit is contained in:
+22
-2
@@ -79,9 +79,24 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define (flac-err->str nr)
|
||||
(cond
|
||||
((= nr 0) "0 = Lost Sync: An error in the stream caused the decoder to lose synchronization.")
|
||||
((= nr 1) "1 = Bad Header: The decoder encountered a corrupted frame header.")
|
||||
((= nr 2) "2 = CRC Mismatch: The frame's data did not match the CRC in the footer.")
|
||||
((= nr 3) "3 = Unparseable Stream: The decoder encountered reserved fields in use in the stream.")
|
||||
((= nr 4) "4 = Bad Metadata: The decoder encountered a corrupted metadata block.")
|
||||
((= nr 5) "5 = Out of bounds: The decoder encountered a otherwise valid frame in which the decoded samples exceeded the range offered by the stated bit depth.")
|
||||
((= nr 6) "6 = Missing Frame: Two adjacent frames had frame numbers increasing by more than 1 or sample numbers increasing by more than the blocksize, indicating that one or more frame/frames was missing between them.")
|
||||
(else (format "~a = Unknown: Unknown status code." nr))
|
||||
)
|
||||
)
|
||||
|
||||
(define (flac-read handle)
|
||||
(let* ((ffi-handler (flac-handle-ffi-decoder-handler handle))
|
||||
(state (ffi-handler 'state)))
|
||||
(state (ffi-handler 'state))
|
||||
(err-hash (make-hash))
|
||||
)
|
||||
(set-flac-handle-stop-reading! handle #f)
|
||||
(set-flac-handle-reading! handle #t)
|
||||
(letrec ((reader (lambda (frame-nr)
|
||||
@@ -98,7 +113,12 @@
|
||||
st frame-nr (ffi-handler 'int-state))
|
||||
)
|
||||
(when (ffi-handler 'has-errno?)
|
||||
(err-sound "Error in stream: ~a" (ffi-handler 'errno))
|
||||
(let ((errno (ffi-handler 'errno)))
|
||||
(unless (eq? (hash-ref err-hash errno #f) #f)
|
||||
(hash-set! err-hash errno #t)
|
||||
(warn-sound "Error in stream: ~a (frame-nr = ~a) (int-state = ~a)"
|
||||
(flac-err->str errno)
|
||||
frame-nr (ffi-handler 'int-state))))
|
||||
)
|
||||
(when (ffi-handler 'has-meta-data?)
|
||||
(ffi-handler 'process-meta-data
|
||||
|
||||
Reference in New Issue
Block a user