Bug 1344614 - Improve GMP clock precision to match Chromium's CDM clock. r?jwwang draft
authorChris Pearce <cpearce@mozilla.com>
Mon, 27 Feb 2017 10:42:59 +1300
changeset 493825 a48ef9da56319d37075c32afcbbeece58a2dbf98
parent 493537 eb23648534779c110f3a1f2baae1849ae4a9c570
child 547938 3b16c9bf1a339bc11beae15eb01b0d3c817b43ce
push id47853
push userbmo:cpearce@mozilla.com
push dateMon, 06 Mar 2017 04:52:07 +0000
reviewersjwwang
bugs1344614
milestone54.0a1
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
dom/media/gmp/GMPPlatform.cpp
--- 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();
   }