Bug 469635. Hold a reference to the Alsa library while we tell it to shut up, so that it doesn't get unloaded and forget about our request. r+sr=roc

This commit is contained in:
Michael Ventnor 2008-12-18 14:22:22 +13:00
parent 22fce0cd91
commit b706becc9a

View File

@ -61,6 +61,7 @@
static int esdref = -1;
static PRLibrary *elib = nsnull;
static PRLibrary *libcanberra = nsnull;
static PRLibrary* libasound = nsnull;
// the following from esd.h
@ -170,6 +171,20 @@ nsSound::Init()
}
}
if (!libasound) {
libasound = PR_LoadLibrary("libasound.so.2");
if (libasound) {
snd_lib_error_set_handler_fn snd_lib_error_set_handler =
(snd_lib_error_set_handler_fn) PR_FindFunctionSymbol(libasound, "snd_lib_error_set_handler");
if (snd_lib_error_set_handler) {
snd_lib_error_set_handler(quiet_error_handler);
} else {
PR_UnloadLibrary(libasound);
libasound = nsnull;
}
}
}
if (!libcanberra) {
libcanberra = PR_LoadLibrary("libcanberra.so.0");
if (libcanberra) {
@ -186,16 +201,6 @@ nsSound::Init()
}
}
PRLibrary* libasound = PR_LoadLibrary("libasound.so.2");
if (libasound) {
snd_lib_error_set_handler_fn snd_lib_error_set_handler =
(snd_lib_error_set_handler_fn) PR_FindFunctionSymbol(libasound, "snd_lib_error_set_handler");
if (snd_lib_error_set_handler)
snd_lib_error_set_handler(quiet_error_handler);
PR_UnloadLibrary(libasound);
}
return NS_OK;
}
@ -210,6 +215,10 @@ nsSound::Shutdown()
PR_UnloadLibrary(libcanberra);
libcanberra = nsnull;
}
if (libasound) {
PR_UnloadLibrary(libasound);
libasound = nsnull;
}
}
#define GET_WORD(s, i) (s[i+1] << 8) | s[i]