NSSound truncates the beginnings of sounds
NSSound truncates the beginnings of sounds
- Subject: NSSound truncates the beginnings of sounds
- From: John Stiles <email@hidden>
- Date: Wed, 17 Sep 2003 17:06:45 -0700
I've begun to notice that NSSound will often drop the beginning of a
sound effect.
Imagine a user in my app clicks a button which is supposed to play a
noise and simultaneously make a sheet drop down. Here's an example of
what I'm trying to do with NSSound:
static NSSound *mySoundEffect = [[NSSound alloc]
initWithContentsOfFile:@"sound.wav" byReference:NO];
[mySoundEffect play];
[NSApp beginSheet:_mySheet modalForWindow:_myWindow
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
Imagine the sheet-dropping takes 3/4s of a second; in that case, the
first 3/4ths of a second worth of sound will not be played.
And it's not just sheets; it's anything that takes CPU. When I do
simple things like:
[myView drawNewImage:myImage]; // this is my custom view object that
will have work to do when Cocoa asks it to redraw, next time through
the event loop
[mySoundEffect play];
If the drawRect method of myView takes a tenth of a second, then I end
up losing the first 1/10th of a second of sound.
What should I do about this? I considered doing a
performSelectorOnMainThread running under the theory that this will
delay the sound playback until after the event loop is running calmly,
but that seems like a wrong sort of answer because it has the potential
to introduce a noticeable delay, and although it would probably solve
the first problem, it might not do anything to the second one.
_______________________________________________
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.