Backed out changeset 3d42767d964d
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 11 Sep 2010 11:15:22 +0200
changeset 52460 e29874ead8b3b57b0045ff07bdf43fbd5c778f12
parent 52454 3d42767d964ddb7bad16648289b0fe3eced7b097
child 52461 cc4df3b40018d32f2566ae6a9e7b6ad3200f7b9d
push id15649
push usermak77@bonardo.net
push dateSat, 11 Sep 2010 09:19:34 +0000
treeherdermozilla-central@73ab2c3c5ad9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b6pre
backs out3d42767d964ddb7bad16648289b0fe3eced7b097
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 3d42767d964d
content/media/nsBuiltinDecoder.cpp
content/media/nsMediaDecoder.cpp
content/media/nsMediaDecoder.h
content/media/wave/nsWaveDecoder.cpp
--- a/content/media/nsBuiltinDecoder.cpp
+++ b/content/media/nsBuiltinDecoder.cpp
@@ -140,18 +140,16 @@ void nsBuiltinDecoder::Shutdown()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   
   if (mShuttingDown)
     return;
 
   mShuttingDown = PR_TRUE;
 
-  StopTimeUpdate();
-
   // This changes the decoder state to SHUTDOWN and does other things
   // necessary to unblock the state machine thread if it's blocked, so
   // the asynchronous shutdown in nsDestroyStateMachine won't deadlock.
   if (mDecoderStateMachine) {
     mDecoderStateMachine->Shutdown();
   }
 
   // Force any outstanding seek and byterange requests to complete
@@ -384,18 +382,16 @@ void nsBuiltinDecoder::MetadataLoaded(PR
     else {
       ChangeState(mNextState);
     }
   }
 
   if (resourceIsLoaded) {
     ResourceLoaded();
   }
-
-  StartTimeUpdate();
 }
 
 void nsBuiltinDecoder::ResourceLoaded()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
   // Don't handle ResourceLoaded if we are shutting down, or if
   // we need to ignore progress data due to seeking (in the case
@@ -772,17 +768,17 @@ void nsBuiltinDecoder::PlaybackPositionC
 
   // Invalidate the frame so any video data is displayed.
   // Do this before the timeupdate event so that if that
   // event runs JavaScript that queries the media size, the
   // frame has reflowed and the size updated beforehand.
   Invalidate();
 
   if (mElement && lastTime != mCurrentTime) {
-    FireTimeUpdate();
+    mElement->DispatchEvent(NS_LITERAL_STRING("timeupdate"));
   }
 }
 
 void nsBuiltinDecoder::DurationChanged()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   MonitorAutoEnter mon(mMonitor);
   PRInt64 oldDuration = mDuration;
--- a/content/media/nsMediaDecoder.cpp
+++ b/content/media/nsMediaDecoder.cpp
@@ -63,24 +63,22 @@
 #endif
 
 // Number of milliseconds between progress events as defined by spec
 #define PROGRESS_MS 350
 
 // Number of milliseconds of no data before a stall event is fired as defined by spec
 #define STALL_MS 3000
 
-// Number of milliseconds between timeupdate events as defined by spec
-#define TIMEUPDATE_MS 250
-
 nsMediaDecoder::nsMediaDecoder() :
   mElement(0),
   mRGBWidth(-1),
   mRGBHeight(-1),
-  mLastCurrentTime(0.0),
+  mProgressTime(),
+  mDataTime(),
   mVideoUpdateLock(nsnull),
   mPixelAspectRatio(1.0),
   mFrameBufferLength(0),
   mPinnedForSeek(PR_FALSE),
   mSizeChanged(PR_FALSE),
   mShuttingDown(PR_FALSE)
 {
   MOZ_COUNT_CTOR(nsMediaDecoder);
@@ -232,64 +230,16 @@ nsresult nsMediaDecoder::StopProgress()
     return NS_OK;
 
   nsresult rv = mProgressTimer->Cancel();
   mProgressTimer = nsnull;
 
   return rv;
 }
 
-static void TimeUpdateCallback(nsITimer* aTimer, void* aClosure)
-{
-  nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
-  decoder->FireTimeUpdate();
-}
-
-void nsMediaDecoder::FireTimeUpdate()
-{
-  if (!mElement)
-    return;
-
-  TimeStamp now = TimeStamp::Now();
-  float time = GetCurrentTime();
-
-  // If TIMEUPDATE_MS has passed since the last timeupdate event fired and the time
-  // has changed, fire a timeupdate event.
-  if ((mTimeUpdateTime.IsNull() ||
-       now - mTimeUpdateTime >= TimeDuration::FromMilliseconds(TIMEUPDATE_MS)) &&
-       mLastCurrentTime != time) {
-    mElement->DispatchEvent(NS_LITERAL_STRING("timeupdate"));
-    mTimeUpdateTime = now;
-    mLastCurrentTime = time;
-  }
-}
-
-nsresult nsMediaDecoder::StartTimeUpdate()
-{
-  if (mTimeUpdateTimer)
-    return NS_OK;
-
-  mTimeUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
-  return mTimeUpdateTimer->InitWithFuncCallback(TimeUpdateCallback,
-                                                this,
-                                                TIMEUPDATE_MS,
-                                                nsITimer::TYPE_REPEATING_SLACK);
-}
-
-nsresult nsMediaDecoder::StopTimeUpdate()
-{
-  if (!mTimeUpdateTimer)
-    return NS_OK;
-
-  nsresult rv = mTimeUpdateTimer->Cancel();
-  mTimeUpdateTimer = nsnull;
-
-  return rv;
-}
-
 void nsMediaDecoder::SetVideoData(const gfxIntSize& aSize,
                                   float aPixelAspectRatio,
                                   Image* aImage)
 {
   nsAutoLock lock(mVideoUpdateLock);
 
   if (mRGBWidth != aSize.width || mRGBHeight != aSize.height ||
       mPixelAspectRatio != aPixelAspectRatio) {
--- a/content/media/nsMediaDecoder.h
+++ b/content/media/nsMediaDecoder.h
@@ -200,20 +200,16 @@ public:
   virtual void Invalidate();
 
   // Fire progress events if needed according to the time and byte
   // constraints outlined in the specification. aTimer is PR_TRUE
   // if the method is called as a result of the progress timer rather
   // than the result of downloaded data.
   virtual void Progress(PRBool aTimer);
 
-  // Fire timeupdate events if needed according to the time constraints
-  // outlined in the specification.
-  virtual void FireTimeUpdate();
-
   // Called by nsMediaStream when the "cache suspended" status changes.
   // If nsMediaStream::IsSuspendedByCache returns true, then the decoder
   // should stop buffering or otherwise waiting for download progress and
   // start consuming data, if possible, because the cache is full.
   virtual void NotifySuspendedStatusChanged() = 0;
 
   // Called by nsMediaStream when some data has been received.
   // Call on the main thread only.
@@ -284,64 +280,47 @@ public:
 protected:
 
   // Start timer to update download progress information.
   nsresult StartProgress();
 
   // Stop progress information timer.
   nsresult StopProgress();
 
-  // Start timer to send timeupdate event
-  nsresult StartTimeUpdate();
-
-  // Stop timeupdate timer
-  nsresult StopTimeUpdate();
-
   // Ensures our media stream has been pinned.
   void PinForSeek();
 
   // Ensures our media stream has been unpinned.
   void UnpinForSeek();
 
 protected:
   // Timer used for updating progress events
   nsCOMPtr<nsITimer> mProgressTimer;
 
-  // Timer used for updating timeupdate events
-  nsCOMPtr<nsITimer> mTimeUpdateTimer;
-
   // This should only ever be accessed from the main thread.
   // It is set in Init and cleared in Shutdown when the element goes away.
   // The decoder does not add a reference the element.
   nsHTMLMediaElement* mElement;
 
   PRInt32 mRGBWidth;
   PRInt32 mRGBHeight;
 
   nsRefPtr<ImageContainer> mImageContainer;
 
   // Time that the last progress event was fired. Read/Write from the
   // main thread only.
   TimeStamp mProgressTime;
 
-  // Time that the last timeupdate event was fired. Read/Write from the
-  // main thread only.
-  TimeStamp mTimeUpdateTime;
-
   // Time that data was last read from the media resource. Used for
   // computing if the download has stalled and to rate limit progress events
   // when data is arriving slower than PROGRESS_MS. A value of null indicates
   // that a stall event has already fired and not to fire another one until
   // more data is received. Read/Write from the main thread only.
   TimeStamp mDataTime;
 
-  // Media 'currentTime' value when the last timeupdate event occurred.
-  // Read/Write from the main thread only.
-  float mLastCurrentTime;
-
   // Lock around the video RGB, width and size data. This
   // is used in the decoder backend threads and the main thread
   // to ensure that repainting the video does not use these
   // values while they are out of sync (width changed but
   // not height yet, etc).
   // Backends that are updating the height, width or writing
   // to the RGB buffer must obtain this lock first to ensure that
   // the video element does not use video data or sizes that are
--- a/content/media/wave/nsWaveDecoder.cpp
+++ b/content/media/wave/nsWaveDecoder.cpp
@@ -1428,17 +1428,16 @@ nsWaveDecoder::MetadataLoaded()
 
   mMetadataLoadedReported = PR_TRUE;
 
   if (mResourceLoaded) {
     ResourceLoaded();
   } else {
     StartProgress();
   }
-  StartTimeUpdate();
 }
 
 void
 nsWaveDecoder::PlaybackEnded()
 {
   if (mShuttingDown) {
     return;
   }
@@ -1548,17 +1547,16 @@ nsWaveDecoder::NotifyDownloadEnded(nsres
 
 void
 nsWaveDecoder::Shutdown()
 {
   if (mShuttingDown)
     return;
 
   mShuttingDown = PR_TRUE;
-  StopTimeUpdate();
 
   nsMediaDecoder::Shutdown();
 
   // An event that gets posted to the main thread, when the media element is
   // being destroyed, to destroy the decoder. Since the decoder shutdown can
   // block and post events this cannot be done inside destructor calls. So
   // this event is posted asynchronously to the main thread to perform the
   // shutdown.
@@ -1675,17 +1673,17 @@ nsWaveDecoder::PlaybackPositionChanged()
   float lastTime = mCurrentTime;
 
   if (mPlaybackStateMachine) {
     mCurrentTime = mPlaybackStateMachine->GetTimeForPositionChange();
   }
 
   if (mElement && lastTime != mCurrentTime) {
     UpdateReadyStateForData();
-    FireTimeUpdate();
+    mElement->DispatchEvent(NS_LITERAL_STRING("timeupdate"));
   }
 }
 
 void
 nsWaveDecoder::SetDuration(PRInt64 /* aDuration */)
 {
   // Ignored by the wave decoder since we can compute the
   // duration directly from the wave data itself.