Closed Bug 176747 Opened 23 years ago Closed 23 years ago

nsISound::Play(aSoundURL) not working except in one weird case

Categories

(Core :: XUL, defect)

x86
Windows 2000
defect
Not set
blocker

Tracking

()

RESOLVED INVALID

People

(Reporter: aaronlev, Assigned: pavlov)

References

Details

I can't add a custom .wav file to typeaheadfind, because nsISound::Play(aSoundURL) is not working. The strange thing is, I can get it to work if I use the debugger, trace into this one line of code and step over it. BOOL PlaySound(const char *aSoundFile,HMODULE aModule,DWORD aOptions) { return (mPlay) ? mPlay(aSoundFile, aModule, aOptions) : FALSE; } If I just let it run normally the sound won't play, either in the debug or release builds.
Blocks: isearch, 176602
Severity: normal → blocker
This stinks, I want my custom sound. Someone gimme a clue to what's going on here? Something to do with threads?
Okay, I figured out what was going wrong. I was using: nsCOMPtr<nsISound> soundInterface = do_CreateInstance("@mozilla.org/sound;1"); The problem with this is that nsISound::Play() uses OnStreamComplete() to play the sound, which might not be called before the com pointer goes out of scope, and thus the destructor gets called before the sound has a chance to get played.
The caller just needs to make sure their COMPtr doesn't go out of scope too soon.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
Component: XP Miscellany → XP Toolkit/Widgets
You need to log in before you can comment on or make changes to this bug.