From b706becc9ad405ae70537c7f94855cae5816ce25 Mon Sep 17 00:00:00 2001 From: Michael Ventnor Date: Thu, 18 Dec 2008 14:22:22 +1300 Subject: [PATCH] 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 --- widget/src/gtk2/nsSound.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/widget/src/gtk2/nsSound.cpp b/widget/src/gtk2/nsSound.cpp index 4b06287a7c5..e022c9d9dee 100644 --- a/widget/src/gtk2/nsSound.cpp +++ b/widget/src/gtk2/nsSound.cpp @@ -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]