I have a problem with some code to monitor when a sound has finished playing;
it works fine under Snow Leopard (MacOS 10.6.8) but not under Lion (MacOS
10.7.4). Since Mountain Lion is still under nondisclosure I will not comment
on its behavior there.
This has been a problem in an existing app for quite a while, but sufficiently
minor that I let is slide. I have a Mac App, "Wraith Scheme", that was built
under MacOS 10.6.8, using Xcode 3.2.6. The app has a rather feline theme, and
a cute feature of it is that if you push a button labeled "meow", an image of
the face of a cat appears, opens its mouth, says "meow", and then disappears.
The problem is, the *same* binary for this works just fine under Snow Leopard
but not under Lion. Here is the relevant code, with a few lines of
instrumentation put in (and I will tell you what the instrumentation produces
in just a moment):
[wraithIconView setImage:wraithIconImageOM]; // "OM" means "Open Mouth".
[self showIconViewAbruptly:YES];
[toPlay play];
while( [toPlay isPlaying] ) {
NSLog(@"Still playing..."); // Instrumentation for debugging.
usleep( 100000 ); // Instrumentation for debugging.
;
}
[wraithIconView setImage:wraithIconImage];
[self showIconViewAbruptly:YES];
In this code, "toPlay" is an instance of NSSound initialized to an aif file
that takes about half a second to play, and "showIconView abruptly" just sets
the alpha of the image to 1 or 0 according to whether the argument is YES or NO.
All this works like gangbusters under 10.6.8 -- the "NSLog" prints about six
times, which is consistent with the length of the sound and the 0.1-second
sleep. But under 10.7.4, The "NSLog" prints forever, or so it seems, even
though the sound has played to all intents and purposes normally; that is, the
kitty has said "meow" and then stopped making any sound. Notwithstanding, my
app is hung in an infinite loop.
So nominally, it looks as if possibly [NSSound isPlaying] is not correctly
indicating sound termination under Lion, or perhaps the sound is actually not
terminating under Lion, or who knows, maybe it is something else.
[NSSound play] is supposed to be asynchronous, so there should be no problem
trying to do other things while the sound is playing.
I have several options, such as (1) rebuild the whole thing under a later XCode
(I will spare you the usual litany of why I didn't do that sooner, but at the
moment I am just lazy), (2) thrash randomly (try explicitly dispatching things
asynchronously, or just put in something like usleep( 600000 ) with no while
loop...), or (3) disable the silly button (but it's cute). I thought I would
first ask here, whether anyone had seen anything like this. I would like to
understand what is going on ...
I haven't filed a bug report on this because the Apple folks will probably
quite properly tell me to go try it under something newer than Xcode 3.2.6, but
I am not quite prepared to abandon 3.2.6 just yet.
I have googled and searched the forums but turned up no leads.
If anyone is terminally curious, you can download a copy of the app that
exhibits this system (works under Snow Leopard, breaks under Lion) -- but
without the two lines of instrumentation -- from
http://jayreynoldsfreeman.com/My/Wraith_Scheme_%2864-bit_version%29.html
Thank you ...
-- Jay Reynolds Freeman
---------------------
[email protected]
http://JayReynoldsFreeman.com (personal web site)
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]