Bug 1311340 - Wire cubeb logging to MOZ_LOG. rmkinetik

MozReview-Commit-ID: 1zhkt29SL5x

--HG--
extra : rebase_source : 0c3eab379e08f8f80293effa1a53abdeea02cbb2
This commit is contained in:
Paul Adenot 2016-10-19 14:39:50 +02:00
Родитель 921f2dc51d
Коммит e95d0f5b59
1 изменённых файлов: 17 добавлений и 0 удалений

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

@ -13,6 +13,7 @@
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Logging.h"
#include "nsThreadUtils.h"
#include "CubebUtils.h"
#include "nsAutoRef.h"
@ -26,6 +27,16 @@ namespace mozilla {
namespace {
LazyLogModule gCubebLog("cubeb");
void CubebLogCallback(const char* aFmt, ...)
{
va_list arglist;
va_start(arglist, aFmt);
MOZ_LOG(gCubebLog, LogLevel::Verbose, (aFmt, arglist));
va_end(arglist);
}
// This mutex protects the variables below.
StaticMutex sMutex;
enum class CubebState {
@ -216,6 +227,12 @@ cubeb* GetCubebContextUnlocked()
NS_WARNING_ASSERTION(rv == CUBEB_OK, "Could not get a cubeb context.");
sCubebState = (rv == CUBEB_OK) ? CubebState::Initialized : CubebState::Uninitialized;
if (MOZ_LOG_TEST(gCubebLog, LogLevel::Verbose)) {
cubeb_set_log_callback(CUBEB_LOG_VERBOSE, CubebLogCallback);
} else if (MOZ_LOG_TEST(gCubebLog, LogLevel::Error)) {
cubeb_set_log_callback(CUBEB_LOG_NORMAL, CubebLogCallback);
}
return sCubebContext;
}