Re: [NSSound isPlaying] fails to indicate sound termination in Lion
Re: [NSSound isPlaying] fails to indicate sound termination in Lion
- Subject: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
- From: Fritz Anderson <email@hidden>
- Date: Sun, 22 Jul 2012 20:00:15 -0500
The essential thing you showed in your code is that you went into a loop while waiting for isPlaying to turn to NO, or at least never returned from your action method back to AppKit. I don't hear you saying otherwise.
If that's what you're doing, bear in mind that other APIs (I'm thinking of Foundation networking; I can all but guarantee that NSSound is the same) are "supposed to run asynchronously," but that means that you can — you _must_ — return from the event that started the network transaction, all the way back to AppKit; and _must not_ block waiting for completion.
It's the run loop, and not your code, that detects completion. The completion notifications will not arrive unless control returns to an AppKit/UIKit runloop. You get the notification through the delegate method. It's not like spawning a thread and waiting for it to clear a flag.
— F
On 22 Jul 2012, at 7:43 PM, Jay Reynolds Freeman wrote:
> The "sleep" was only for instrumentation; without the sleep and the NSLog, the code exhibits the problem described. And [NSSound play] is supposed to run asynchronously ...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden