• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSSound isPlaying] fails to indicate sound termination in Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSSound isPlaying] fails to indicate sound termination in Lion


  • Subject: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 22 Jul 2012 21:38:45 -0500

On Jul 22, 2012, at 9:24 PM, Jens Alfke wrote:

> On Jul 22, 2012, at 6:43 PM, Jay Reynolds Freeman <email@hidden> wrote:
>
>> Since my app has nothing to do while waiting for the sound to play, a polling loop on "isPlaying" is actually a good deal less code (only two lines) than setting up a delegate with "-sound:didFinishPlaying" implemented.
>
> It may be less code, but it's bad practice. It locks up the thread, preventing the runloop from performing other activities, and it consumes a lot of CPU unless you put in a sleep call.
>
> If you really have to block, use a loop that spins the runloop, like this:
>
>        while (!readyToStop()) {
>            if (![[NSRunLoop currentRunLoop] runMode: someCustomRunLoopMode
>                                          beforeDate: [NSDate distantFuture]])
>                break;
>        }

Actually, this defeats the purpose.  By specifying a custom run loop mode, rather than the default run loop mode, you are *not* providing an opportunity for any framework run loop sources to be serviced.  They could not possibly be scheduled on your custom run loop mode.

Regards,
Ken


_______________________________________________

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

  • Follow-Ups:
    • Re: [NSSound isPlaying] fails to indicate sound termination in Lion
      • From: Jay Reynolds Freeman <email@hidden>
References: 
 >[NSSound isPlaying] fails to indicate sound termination in Lion (From: Jay Reynolds Freeman <email@hidden>)
 >Re: [NSSound isPlaying] fails to indicate sound termination in Lion (From: Fritz Anderson <email@hidden>)
 >Re: [NSSound isPlaying] fails to indicate sound termination in Lion (From: Jay Reynolds Freeman <email@hidden>)
 >Re: [NSSound isPlaying] fails to indicate sound termination in Lion (From: Ken Thomases <email@hidden>)
 >Re: [NSSound isPlaying] fails to indicate sound termination in Lion (From: Jay Reynolds Freeman <email@hidden>)

  • Prev by Date: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
  • Next by Date: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
  • Previous by thread: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
  • Next by thread: Re: [NSSound isPlaying] fails to indicate sound termination in Lion
  • Index(es):
    • Date
    • Thread