зеркало из https://github.com/mozilla/gecko-dev.git
Bug 182451. Beep when first key pressed in win95/98. r=biesi, sr=blizzard
This commit is contained in:
Родитель
a6a4a73dac
Коммит
2bf2f215f4
|
@ -520,23 +520,21 @@ nsTypeAheadFind::KeyPress(nsIDOMEvent* aEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Deal with nsISound impl quirks in Windows
|
||||
if (!mIsSoundInitialized) {
|
||||
// Don't play a sound, just make sure sound system is initialized
|
||||
// This makes sure system sound library (winmm.dll) is loaded so that
|
||||
// This makes sure system sound library is loaded so that
|
||||
// there's no lag before the first sound is played
|
||||
// by waiting for the first keystroke, we still get the startup time benefits
|
||||
// by waiting for the first keystroke, we still get the startup time benefits.
|
||||
mIsSoundInitialized = PR_TRUE;
|
||||
mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
|
||||
if (mSoundInterface) {
|
||||
mSoundInterface->PlaySystemSound("");
|
||||
mSoundInterface->Init();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
// After each keystroke, destroy sound object to free up memory
|
||||
// allocated for error sound, otherwise Windows' nsISound impl
|
||||
// holds onto the last played sound.
|
||||
// holds onto the last played sound, using up memory.
|
||||
mSoundInterface = nsnull;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,4 +34,10 @@ interface nsISound : nsISupports
|
|||
*/
|
||||
void playSystemSound(in string soundAlias);
|
||||
void beep();
|
||||
|
||||
/**
|
||||
* Not strictly necessary, but avoids delay before first sound.
|
||||
* The various methods on nsISound call Init() if they need to.
|
||||
*/
|
||||
void init();
|
||||
};
|
||||
|
|
|
@ -77,13 +77,10 @@ nsresult NS_NewSound(nsISound** aSound)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// not currently used.. may go away
|
||||
NS_METHOD nsSound::Init(void)
|
||||
NS_IMETHODIMP nsSound::Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_METHOD nsSound::Beep()
|
||||
{
|
||||
|
|
|
@ -223,6 +223,12 @@ nsSound::Beep()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::PlaySystemSound(const char *aSoundName)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,8 @@ nsSound::~nsSound()
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsSound::Init()
|
||||
NS_IMETHODIMP
|
||||
nsSound::Init()
|
||||
{
|
||||
/* we don't need to do esd_open_sound if we are only going to play files
|
||||
but we will if we want to do things like streams, etc
|
||||
|
|
|
@ -42,7 +42,6 @@ class nsSound : public nsISound,
|
|||
NS_DECL_NSISTREAMLOADEROBSERVER
|
||||
|
||||
private:
|
||||
nsresult Init();
|
||||
PRBool mInited;
|
||||
|
||||
};
|
||||
|
|
|
@ -78,7 +78,8 @@ nsSound::~nsSound()
|
|||
}
|
||||
}
|
||||
|
||||
nsresult nsSound::Init()
|
||||
NS_IMETHODIMP
|
||||
nsSound::Init()
|
||||
{
|
||||
/* we don't need to do esd_open_sound if we are only going to play files
|
||||
but we will if we want to do things like streams, etc
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
NS_DECL_NSISTREAMLOADEROBSERVER
|
||||
|
||||
private:
|
||||
nsresult Init();
|
||||
PRBool mInited;
|
||||
|
||||
};
|
||||
|
|
|
@ -223,6 +223,12 @@ nsSound::Beep()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSound::PlaySystemSound(const char *aSoundName)
|
||||
{
|
||||
|
|
|
@ -170,6 +170,11 @@ NS_METHOD nsSound::Play(nsIURL *aURL)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
nsresult rv;
|
||||
|
|
|
@ -63,7 +63,7 @@ nsSound::~nsSound()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsSound::Init()
|
||||
NS_IMETHODIMP nsSound::Init()
|
||||
{
|
||||
if (mInited) return NS_OK;
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ class nsSound : public nsISound,
|
|||
NS_DECL_NSISTREAMLOADEROBSERVER
|
||||
|
||||
private:
|
||||
nsresult Init();
|
||||
PRBool mInited;
|
||||
};
|
||||
|
||||
|
|
|
@ -165,6 +165,21 @@ NS_IMETHODIMP nsSound::Play(nsIURL *aURL)
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSound::Init()
|
||||
{
|
||||
CWinMM& theMM = CWinMM::GetModule();
|
||||
|
||||
// This call halts a sound if it was still playing.
|
||||
// We have to use the sound library for something to make sure
|
||||
// it is initialized.
|
||||
// If we wait until the first sound is played, there will
|
||||
// be a time lag as the library gets loaded.
|
||||
theMM.PlaySound(nsnull, nsnull, SND_PURGE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias)
|
||||
{
|
||||
PurgeLastSound();
|
||||
|
|
|
@ -50,7 +50,7 @@ nsSound::~nsSound()
|
|||
|
||||
}
|
||||
|
||||
nsresult nsSound::Init()
|
||||
NS_IMETHODIMP nsSound::Init()
|
||||
{
|
||||
|
||||
#ifdef DEBUG_faulkner
|
||||
|
|
|
@ -40,10 +40,6 @@ class nsSound : public nsISound,
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISOUND
|
||||
NS_DECL_NSISTREAMLOADEROBSERVER
|
||||
|
||||
private:
|
||||
nsresult Init();
|
||||
|
||||
};
|
||||
|
||||
#endif /* __nsSound_h__ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче