Bug 469635 - Remove loading of libasound and installation of quiet error

handler since it's not serving any purpose.  Also fix failure handling case
when calling esd_open_sound.

--HG--
extra : rebase_source : 17f97c7fe10e5cdf13b781e1799affe464d99489
This commit is contained in:
Matthew Gregan 2009-02-22 14:19:30 +13:00
parent 435805d7e3
commit 2b5e16d2e4

View File

@ -61,7 +61,6 @@
static int esdref = -1;
static PRLibrary *elib = nsnull;
static PRLibrary *libcanberra = nsnull;
static PRLibrary* libasound = nsnull;
// the following from esd.h
@ -101,26 +100,6 @@ static ca_context_destroy_fn ca_context_destroy;
static ca_context_play_fn ca_context_play;
static ca_context_change_props_fn ca_context_change_props;
/* we provide a blank error handler to silence ALSA's stderr
messages on computers with no sound devices */
typedef void (*snd_lib_error_handler_t) (const char* file,
int line,
const char* function,
int err,
const char* format,
...);
typedef int (*snd_lib_error_set_handler_fn) (snd_lib_error_handler_t handler);
static void
quiet_error_handler(const char* file,
int line,
const char* function,
int err,
const char* format,
...)
{
}
NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
////////////////////////////////////////////////////////////////////////
@ -131,8 +110,7 @@ nsSound::nsSound()
nsSound::~nsSound()
{
/* see above comment */
if (esdref != -1) {
if (esdref > 0) {
EsdCloseType EsdClose = (EsdCloseType) PR_FindFunctionSymbol(elib, "esd_close");
if (EsdClose)
(*EsdClose)(esdref);
@ -151,19 +129,16 @@ nsSound::Init()
mInited = PR_TRUE;
if (!elib) {
/* 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 */
EsdOpenSoundType EsdOpenSound;
elib = PR_LoadLibrary("libesd.so.0");
if (elib) {
EsdOpenSound = (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound");
// Attempt to initialize Esound.
EsdOpenSoundType EsdOpenSound = (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound");
if (!EsdOpenSound) {
PR_UnloadLibrary(elib);
elib = nsnull;
} else {
esdref = (*EsdOpenSound)("localhost");
if (!esdref) {
if (esdref < 0) {
PR_UnloadLibrary(elib);
elib = nsnull;
}
@ -171,16 +146,6 @@ nsSound::Init()
}
}
if (!libasound) {
PRFuncPtr func = PR_FindFunctionSymbolAndLibrary("snd_lib_error_set_handler",
&libasound);
if (libasound) {
snd_lib_error_set_handler_fn snd_lib_error_set_handler =
(snd_lib_error_set_handler_fn) func;
snd_lib_error_set_handler(quiet_error_handler);
}
}
if (!libcanberra) {
libcanberra = PR_LoadLibrary("libcanberra.so.0");
if (libcanberra) {
@ -211,10 +176,6 @@ 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]
@ -380,7 +341,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
buf[j + 1] = audio[j];
}
audio = buf;
audio = buf;
}
#endif