Re: NSSound doesn't play
Re: NSSound doesn't play
- Subject: Re: NSSound doesn't play
- From: Lorenzo <email@hidden>
- Date: Sat, 26 Jul 2003 20:33:15 +0200
Thank you. Me too I am building complicated threads and appkit callings to
graphic routines... I hope Apple will fix that soon.
Best Regards
--
Lorenzo
email: email@hidden
>
From: Don Yacktman <email@hidden>
>
Date: Sat, 26 Jul 2003 12:17:48 -0600
>
To: Lorenzo <email@hidden>
>
Subject: Re: NSSound doesn't play
>
>
On Saturday, July 26, 2003, at 09:04 AM, Lorenzo wrote:
>
> Hi list,
>
> I have a problem with two NSSounds
>
>
That right there is all you need to say -- most of us have a problem
>
with the class: it sucks!
>
>
> just before a small animation starts
>
>
>
> The first one plays well:
>
> I can hear the sound playing while the object moves in the window
>
> (fine).
>
>
>
>
>
> The second sound plays only at the end of the loop (wrong):
>
> I can hear the last 2 seconds of the sound playing only after the loop
>
> ended. And I never hear the first two seconds of the sound. It seems
>
> that
>
> during the animation loop the sound is off, then at the end of the
>
> animation
>
> the sound turns on automatically. If I delete the code about the
>
> animation,
>
> the sound plays properly. But if I reinclude the animation loop it
>
> fails
>
> again.
>
> The strange thing is that if I change @"abortSound" to @"startSound",
>
> it
>
> works properly again. So I suppose something strange is inside the
>
> sound
>
> abortSound.aiff.
>
>
>
> What could it be?
>
> Any idea?
>
>
In my experience, NSSound loads up short buffers of sound at a time and
>
plays them; several buffers need to be played for a complete sound to
>
be heard. The call to put out the next buffer seems to come through the
>
main event loop. Therefore, any long running operation that doesn't
>
return to the event loop right away can interfere wtih NSSound
>
playback.
>
>
My workaround (and it still isn't 100% effective) is to use delayed
>
performs and/or timers to implement my animation loops and break up any
>
longer running methods into chunks that get called from the main event
>
loop. That way, as a long running operation happens, I periodically
>
return to the event loop so that NSSound can be serviced. I call it
>
"poor man's threading". Of course, you could spawn a separate thread,
>
too, but drawing needs to be done from the main thread, so things can
>
get pretty hairy going that route...
>
>
--
>
Later,
>
>
Don Yacktman
>
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.