Bug 1344614 - Improve GMP clock precision to match Chromium's CDM clock. r?jwwang
The clock that GMP currently exposes to CDMs has second precision. Whereas the
clock that Chromium exposes to CDMs has microsecond precision. We should use
the same clock as Chromium does (since we have its code in our tree already) so
that our CDM harness is as compatible to Chromium as possible.
MozReview-Commit-ID: FssZZFg4vhn
--- a/dom/media/gmp/GMPPlatform.cpp
+++ b/dom/media/gmp/GMPPlatform.cpp
@@ -5,16 +5,17 @@
#include "GMPPlatform.h"
#include "GMPStorageChild.h"
#include "GMPTimerChild.h"
#include "mozilla/Monitor.h"
#include "GMPChild.h"
#include "mozilla/Mutex.h"
#include "base/thread.h"
+#include "base/time.h"
#include "mozilla/ReentrantMonitor.h"
#include <ctime>
namespace mozilla {
namespace gmp {
static MessageLoop* sMainLoop = nullptr;
@@ -215,18 +216,21 @@ SetTimerOnMainThread(GMPTask* aTask, int
GMPTimerChild* timers = sChild->GetGMPTimers();
NS_ENSURE_TRUE(timers, GMPGenericErr);
return timers->SetTimer(aTask, aTimeoutMS);
}
GMPErr
GetClock(GMPTimestamp* aOutTime)
{
- *aOutTime = time(0) * 1000;
- return GMPNoErr;
+ if (!aOutTime) {
+ return GMPGenericErr;
+ }
+ *aOutTime = base::Time::Now().ToDoubleT() * 1000.0;
+ return GMPNoErr;
}
void
InitPlatformAPI(GMPPlatformAPI& aPlatformAPI, GMPChild* aChild)
{
if (!sMainLoop) {
sMainLoop = MessageLoop::current();
}