cocoa: fix `play-sound'

by expanding paths properly and checking whether playing
 succeeds

original commit: ca8c6a813313acecd19ccc463c0f48bd9c3aa836
This commit is contained in:
Matthew Flatt 2011-03-10 08:06:35 -06:00
parent 4c7410e291
commit 372646be39

View File

@ -20,17 +20,16 @@
(define (play-sound path async?) (define (play-sound path async?)
(let ([s (as-objc-allocation (let ([s (as-objc-allocation
(tell (tell MySound alloc) (tell (tell MySound alloc)
initWithContentsOfFile: #:type _NSString (if (path? path) initWithContentsOfFile: #:type _NSString (path->string
(path->string path) (path->complete-path path))
path)
byReference: #:type _BOOL #t))] byReference: #:type _BOOL #t))]
[sema (make-semaphore)]) [sema (make-semaphore)])
(tellv s setDelegate: s) (tellv s setDelegate: s)
(set-ivar! s sema sema) (set-ivar! s sema sema)
(tellv s retain) ; don't use `retain', because we dont' want auto-release (tellv s retain) ; don't use `retain', because we dont' want auto-release
(tellv s play) (and (tell #:type _BOOL s play)
(if async? (if async?
#t #t
(begin (begin
(semaphore-wait sema) (semaphore-wait sema)
(get-ivar s result))))) (get-ivar s result))))))