Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap timed-pop-filtered into a synchronizable event
- Loading branch information
Showing
3 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#lang racket/base | ||
|
||
(require ffi/unsafe/introspection | ||
racket/contract | ||
racket/place | ||
"gst.rkt") | ||
|
||
(provide (contract-out [make-bus-channel | ||
(->* (gobject?) | ||
((listof symbol?) | ||
#:timeout exact-nonnegative-integer?) | ||
evt?)])) | ||
|
||
(define bus% (gst 'Bus)) | ||
|
||
(define message% (gst 'Message)) | ||
|
||
(define clock-time-none ((gst 'CLOCK_TIME_NONE))) | ||
|
||
(define (make-bus-channel bus [filters '(any)] | ||
#:timeout [timeout clock-time-none]) | ||
(define bus-pipe | ||
(place chan | ||
(let*-values ([(bus-ptr timeout filters) | ||
(apply values (place-channel-get chan))] | ||
[(bus) (gobject-cast bus-ptr bus%)]) | ||
(let loop () | ||
(define msg | ||
(send bus timed-pop-filtered timeout filters)) | ||
(place-channel-put chan (and msg | ||
(gtype-instance-pointer msg))) | ||
(loop))))) | ||
(place-channel-put bus-pipe (list (gtype-instance-pointer bus) | ||
timeout | ||
filters)) | ||
;; (define bus-pipe (make-channel)) | ||
;; (thread | ||
;; (let loop () | ||
;; (define msg | ||
;; (send bus timed-pop-filtered timeout filters)) | ||
;; (channel-put bus-pipe (and msg | ||
;; (gtype-instance-pointer msg))) | ||
;; (loop))) | ||
(wrap-evt bus-pipe (lambda (ptr) (and ptr | ||
(gstruct-cast ptr message%))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#lang racket/base | ||
|
||
(require ffi/unsafe/introspection) | ||
|
||
(provide gst) | ||
|
||
(define gst (introspection 'Gst)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters