Bug 469635. Silence ALSA warnings when there is no sound device. r+sr=roc

--HG--
extra : rebase_source : 81cb6c89ffffd534a478151a7aa450c42b36a469
This commit is contained in:
Michael Ventnor 2008-12-17 15:16:01 +13:00
Родитель 14634e7506
Коммит 00576b552f
1 изменённых файлов: 30 добавлений и 0 удалений

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

@ -100,6 +100,26 @@ 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)
////////////////////////////////////////////////////////////////////////
@ -166,6 +186,16 @@ 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;
}