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