Bug 182451. Beep when first key pressed in win95/98. r=biesi, sr=blizzard

This commit is contained in:
aaronl%netscape.com 2002-12-14 00:27:33 +00:00
Родитель a6a4a73dac
Коммит 2bf2f215f4
15 изменённых файлов: 50 добавлений и 22 удалений

Просмотреть файл

@ -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__ */