Chris Pirillo had an interesting blog post the other day with the rather uninformative title of "Windows Vista Sound Problems". He has a reader who built a shutdown sound that is almost 2 minutes long, and that reader is upset that the system isn't playing his entire shutdown sound when he shuts is system down.
Chris speculates that it might be tied to the sound event process or to audio driver limitations, but the actual answer is actually much simpler, and is related to the way that the shell handles the shutdown sound.
One of the most significant pieces of feedback that we received about Windows XP was that people (especially people with laptops) were quite upset at the amount of time that it took for XP to shutdown. You could see dramatic proof of this by simply walking around the halls here at Microsoft - you'd see people going from their office to a meeting with their laptop lids cracked partly open. The big reason for this was that XP didn't reliably shut down the system - you'd close the lid of your laptop, stick it in your laptop case and head off to your meeting, when you got there you'd burn your hands because the laptop never shut down, even after 5 minutes with the lid closed.
For Vista, the power management folks decided that they were going to fix this problem - when you closed your laptop (or shut off your computer), they WERE going to shut down the machine. This makes a ton of sense - the act of closing the lid on the laptop is a clear indication that the customers intent is to stop using their machine, so the system should turn itself off when this happens.
This decision had some consequences though. On Windows XP, an application was allowed to delay system shutdown indefinitely - this was a major cause of the overheated laptop problem; on Vista, the system IS going to shut down, even if your application isn't ready for it. So if your application takes a long time to exit (and Microsoft applications are absolutely NOT excluded from this list), than it's going to have the rug yanked out from under its feet.
Since the shutdown process is effectively synchronous, the shell (explorer.exe) attempts to limit the size of the WAV file that's played during system shutdown (it uses the file size as a first order approximation of the length of the sound). If the .WAV file that's registered for the shutdown sound is larger than 4M in size, it won't be played.
So if Chris's reader reworked his file to keep it under 4M in size (which probably can be done with a reduction in sample rate and channel count) than Explorer will happily play the sound.
However Chris's reader may still not be happy with the results. To understand why, you need to dig a bit deeper into the shutdown process.
The Windows shutdown process is (very roughly - this is a 100,000 foot approximation, the actual process is much more complicated):
Remember my comment above about shutting down the user's applications? Well, explorer is still one of the user's applications, and it's subject to the same termination rules as every other application. Some number of seconds into playing the shutdown sound, NTUSER will decide that the explorer is hung and will bring up the "This application is hung, do you want to kill it?" screen (the reason will be something like "Explorer / Playing Logoff sound").
What happens next depends on what the user answers (or has previously answered). If the user answers "yes" to the "Do you wish to terminate this application" prompt, then the system enters "forced shutdown" mode. If they answered "no", than the system will wait until all the applications have terminated.
If the system is in "forced shutdown" mode, than 30 seconds after the prompt, the system WILL kill the remaining applications, regardless of whether or not they're shut down. If Explorer is still playing the logoff sound at that time, it'll be yanked as well, and the logoff sound will be cut short.
I don't have Vista handy or I'd test this myself right now, but do ‘WaitToKillAppTimeout’ and ‘HungAppTimeout’ in HKCU\Control Panel\Desktop\ still work to extend or contract the time allowed to shut down applications, thus giving a longer playback?
If getting it to play at all just requires lowering the filesize, then mp3-encoding it in sound recorder would be the logical solution. ;)
Errr... I think closing the lid of a laptop makes it go to sleep, not shut down.
And I don't agree that Vista handles this any better. I have suffered from the "hot laptop" problem which did not sleep when I closed the lid.
Makes sense to me.
The only question I have is the bit where you say "or has previously answered" -- what if you've never answered that question before and you just close the lid of your laptop? In this particular case, it might shutdown on its own after it's played the sound anyway, but what if it really WAS hung?
El Guapo: It depends on how the system's configured. You can say that closing the lid sleeps (the default) or that closing the lid shuts the system down.
Dean: As El Guapo pointed out, the default action on the laptop is to sleep, so it sleeps immediately (and restores very quickly (under 5 seconds on my laptop)).
This logic only kicks in for shutdown.
foxyshadis: You can't use MP3s for system sounds. It's silly, and it sucks, but you can't. Interestingly enough, it would probably be slower - it takes a non trivial amount of time to start playing an MP3, while we can start playing a .WAV file in under 100ms.
> And I don't agree that Vista handles this any better.
Er, it handles it MUCH better. Just because it's happened "once" doesn't mean it's just as bad as Windows XP (where it used to happen *all the time* for me.
> This logic only kicks in for shutdown.
Fair enough, but you can still configure it to shutdown when you close the lid. I guess what I mean is, does the system handle closing the lid differently to clicking "shutdown" (since you're usually still around to click on confirmation dialogs and whatnot when you click "shutdown" but not when you close the lid).
I guess this getting a bit off-topic for the originaly post...
Personally, I usually turn my startup/shutdown sounds off. I can't imagine anyone CHOOSING to sit there and listen to a 2 minute-long shutdown sound :-)
Dean, I also can't imagine a startup or shutdown sound that is that long. The shutdown sound is one of the shortest that ships in Vista (I believe it's around .5 seconds).
I should try to see what happens on my laptop, I honestly don't know what it will do.
To Larry and El Guapo's comment,
My laptops are configured to sleep when the lid is closed. I would hope, though, that if a shutdown has been started and I close the lid. (Start->Shutdown. Pause. Close lid) That the sleep wouldn't kick in, but the shutdown would allowed finish.
Under XP that doesn't happen. It usually sleeps during the shutdown. Absolutely, incredibly the wrong behavior. I can't tell you how many times I've opened the lid hours later, had the machine wakes up and announces "shutting down" and then shuts down.
My Vista laptop does the same thing on occasion.
> > And I don't agree that Vista handles this any better.
> Er, it handles it MUCH better. Just because it's happened "once" doesn't mean it's just as bad as Windows XP (where it used to happen *all the time* for me.
This is exactly reason for most of my bitching about Vista...when I close the lid I wan't that computer in sleep mode - and with Vista on my IBM/Lenovo T60 I often get "burned" fingers, not to mention empty battery
Larry, et al,
I have Vista Ultimate on a brand spanking new Dell XPS laptop with all the blinking lights and everything (oh yes, it is that cool).
Microsoft made the CORRECT choice. I have my laptop configured to hibernate when I close the lid. And yes, when I close the lid, that means hibernate - NOW.
Do not pass Go.
Do not collect $200.
Go straight to Save state and hibernate so I can pack you up and go to my next meeting or back to the office.
Thank you to both you, Mr. Osterman, and Lord Chen for all the hard work you guys put into making Windows the OS it is. If I could, I'd send both of you flowers.
For those of you still having shutdown issues with Vista, I would say it is time for you to investigate what apps you have that may be misbehaving. And don't forget drivers. In fact, ESPECIALLY drivers since they run with all kinds of priviledge.
JamesNT's right. Vista actually has extensive logging that will let you know details about what's causing slowdowns on suspend and resume.
If you start the event viewer and navigate to Applications and Services Logs\Microsoft\Windows\Diagnostics-Performance, you can find a series of diagnostic log entries that measure perf issues on your machine.
You can use mp3s through the acm codec. ;) Assuming fraunhofer is still included with Vista. The problem is that PlaySound will decode the entire thing to PCM in memory before it starts playing - I did this on 95 back in the day, and it was pretty obnoxious, but now I can decode a short song in well under a second - but yeah, that's definitely an extra playtime hit.
I know it's not audio related, but I'm assuming there is some logic that say:
"If an external monitor is connected and on, AND the lid is closed, do nothing"
I've got Vista at home but not at work, and i don't have a laptop, but i hope that case is countered for.
That sounds pretty lame. I thought Vista was supposed to fix all those problems with apps blocking the shutdown attempt ? And now you're telling us we have to go dig through the event log for clues ? I suppose that works if you're a Windows developer, but what about regular users ? Why can't it just work ?