flac problems for os threads solved.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#lang racket/base
|
||||
|
||||
(require "../flac-decoder.rkt")
|
||||
|
||||
(define (test-flac-thread flac-path #:pool [pool #f])
|
||||
(define result-ch (make-channel))
|
||||
|
||||
(define (start)
|
||||
(thread
|
||||
(lambda ()
|
||||
(with-handlers ([exn:fail?
|
||||
(lambda (e)
|
||||
(channel-put result-ch
|
||||
(list 'error (exn-message e))))])
|
||||
(define frames 0)
|
||||
(define buffers 0)
|
||||
(define bytes 0)
|
||||
(define fmt #f)
|
||||
|
||||
(define h
|
||||
(flac-open
|
||||
flac-path
|
||||
|
||||
;; stream-info callback
|
||||
(lambda (info)
|
||||
(set! fmt info)
|
||||
(printf "format: ~s\n" info)
|
||||
(flush-output))
|
||||
|
||||
;; audio callback
|
||||
(lambda (info buffer len)
|
||||
(set! buffers (add1 buffers))
|
||||
(set! bytes (+ bytes len))
|
||||
(define blocksize (hash-ref info 'blocksize #f))
|
||||
(when (integer? blocksize)
|
||||
(set! frames (+ frames blocksize)))
|
||||
|
||||
;; af en toe iets printen, zodat je ziet dat hij loopt
|
||||
(when (zero? (modulo buffers 500))
|
||||
(printf "buffers=~a bytes=~a frames=~a\n"
|
||||
buffers bytes frames)
|
||||
(flush-output)))))
|
||||
|
||||
(unless h
|
||||
(error 'test-flac-thread "could not open FLAC file: ~a" flac-path))
|
||||
|
||||
(define state (flac-read h))
|
||||
|
||||
(channel-put result-ch
|
||||
(list 'ok
|
||||
'state state
|
||||
'buffers buffers
|
||||
'bytes bytes
|
||||
'frames frames
|
||||
'format fmt))))
|
||||
#:pool pool)
|
||||
)
|
||||
|
||||
(start)
|
||||
(start)
|
||||
(start)
|
||||
|
||||
(channel-get result-ch)
|
||||
(channel-get result-ch)
|
||||
(channel-get result-ch)
|
||||
)
|
||||
|
||||
|
||||
; (test-flac-thread "\\\\panderleou\\music\\Jazz\\LA4\\LA4 - Zaca\\01 Zaca.flac")
|
||||
Reference in New Issue
Block a user