From 26bd50e7d0c37b4bb0dbd2f579519f21510d91a6 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Sat, 11 Sep 2010 11:15:22 +0200 Subject: [PATCH] Backed out changeset 3d42767d964d --- content/media/nsBuiltinDecoder.cpp | 6 +--- content/media/nsMediaDecoder.cpp | 54 ++-------------------------- content/media/nsMediaDecoder.h | 21 ----------- content/media/wave/nsWaveDecoder.cpp | 4 +-- 4 files changed, 4 insertions(+), 81 deletions(-) diff --git a/content/media/nsBuiltinDecoder.cpp b/content/media/nsBuiltinDecoder.cpp index 7105f45e5ff..bdef0ea9027 100644 --- a/content/media/nsBuiltinDecoder.cpp +++ b/content/media/nsBuiltinDecoder.cpp @@ -145,8 +145,6 @@ void nsBuiltinDecoder::Shutdown() 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. @@ -389,8 +387,6 @@ void nsBuiltinDecoder::MetadataLoaded(PRUint32 aChannels, if (resourceIsLoaded) { ResourceLoaded(); } - - StartTimeUpdate(); } void nsBuiltinDecoder::ResourceLoaded() @@ -777,7 +773,7 @@ void nsBuiltinDecoder::PlaybackPositionChanged() Invalidate(); if (mElement && lastTime != mCurrentTime) { - FireTimeUpdate(); + mElement->DispatchEvent(NS_LITERAL_STRING("timeupdate")); } } diff --git a/content/media/nsMediaDecoder.cpp b/content/media/nsMediaDecoder.cpp index f7d9f40b87b..9925fb5efa4 100644 --- a/content/media/nsMediaDecoder.cpp +++ b/content/media/nsMediaDecoder.cpp @@ -68,14 +68,12 @@ // 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), @@ -237,54 +235,6 @@ nsresult nsMediaDecoder::StopProgress() return rv; } -static void TimeUpdateCallback(nsITimer* aTimer, void* aClosure) -{ - nsMediaDecoder* decoder = static_cast(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) diff --git a/content/media/nsMediaDecoder.h b/content/media/nsMediaDecoder.h index 5078e1745f5..2fd0bf2faf0 100644 --- a/content/media/nsMediaDecoder.h +++ b/content/media/nsMediaDecoder.h @@ -205,10 +205,6 @@ public: // 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 @@ -289,12 +285,6 @@ protected: // 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(); @@ -305,9 +295,6 @@ protected: // Timer used for updating progress events nsCOMPtr mProgressTimer; - // Timer used for updating timeupdate events - nsCOMPtr 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. @@ -322,10 +309,6 @@ protected: // 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 @@ -333,10 +316,6 @@ protected: // 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 diff --git a/content/media/wave/nsWaveDecoder.cpp b/content/media/wave/nsWaveDecoder.cpp index 4b59f4c4d5a..c9df589d233 100644 --- a/content/media/wave/nsWaveDecoder.cpp +++ b/content/media/wave/nsWaveDecoder.cpp @@ -1433,7 +1433,6 @@ nsWaveDecoder::MetadataLoaded() } else { StartProgress(); } - StartTimeUpdate(); } void @@ -1553,7 +1552,6 @@ nsWaveDecoder::Shutdown() return; mShuttingDown = PR_TRUE; - StopTimeUpdate(); nsMediaDecoder::Shutdown(); @@ -1680,7 +1678,7 @@ nsWaveDecoder::PlaybackPositionChanged() if (mElement && lastTime != mCurrentTime) { UpdateReadyStateForData(); - FireTimeUpdate(); + mElement->DispatchEvent(NS_LITERAL_STRING("timeupdate")); } }