Bug 1160695 - Make MediaDecoder::DurationChanged take a duration argument rather than reading it back synchronously from the MDSM. r=jww

This commit is contained in:
Bobby Holley 2015-06-03 14:46:08 -07:00
parent b109b7040a
commit 6f9facd3ca
4 changed files with 10 additions and 6 deletions

View File

@ -1067,12 +1067,12 @@ void MediaDecoder::UpdateLogicalPosition(MediaDecoderEventVisibility aEventVisib
}
}
void MediaDecoder::DurationChanged()
void MediaDecoder::DurationChanged(TimeUnit aNewDuration)
{
MOZ_ASSERT(NS_IsMainThread());
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
int64_t oldDuration = mDuration;
mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
mDuration = aNewDuration.ToMicroseconds();
// Duration has changed so we should recompute playback rate
UpdatePlaybackRate();

View File

@ -520,7 +520,7 @@ public:
// Called by the state machine to notify the decoder that the duration
// has changed.
void DurationChanged();
void DurationChanged(media::TimeUnit aNewDuration);
bool OnStateMachineTaskQueue() const override;

View File

@ -1352,7 +1352,8 @@ void MediaDecoderStateMachine::UpdatePlaybackPositionInternal(int64_t aTime)
DECODER_LOG("Setting new end time to %lld", aTime);
mEndTime = aTime;
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &MediaDecoder::DurationChanged);
NS_NewRunnableMethodWithArg<TimeUnit>(mDecoder, &MediaDecoder::DurationChanged,
TimeUnit::FromMicroseconds(GetDuration()));
AbstractThread::MainThread()->Dispatch(event.forget());
}
}
@ -1517,7 +1518,8 @@ void MediaDecoderStateMachine::UpdateEstimatedDuration(int64_t aDuration)
mozilla::Abs(aDuration - duration) > ESTIMATED_DURATION_FUZZ_FACTOR_USECS) {
SetDuration(aDuration);
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &MediaDecoder::DurationChanged);
NS_NewRunnableMethodWithArg<TimeUnit>(mDecoder, &MediaDecoder::DurationChanged,
TimeUnit::FromMicroseconds(GetDuration()));
AbstractThread::MainThread()->Dispatch(event.forget());
}
}

View File

@ -20,6 +20,8 @@ extern PRLogModuleInfo* GetMediaSourceLog();
#define MSE_DEBUG(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Debug, ("MediaSourceDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
#define MSE_DEBUGV(arg, ...) MOZ_LOG(GetMediaSourceLog(), mozilla::LogLevel::Verbose, ("MediaSourceDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
using namespace mozilla::media;
namespace mozilla {
class SourceBufferDecoder;
@ -210,7 +212,7 @@ MediaSourceDecoder::SetMediaSourceDuration(double aDuration, MSRangeRemovalActio
mReader->SetMediaSourceDuration(mMediaSourceDuration);
}
MediaDecoder::DurationChanged();
MediaDecoder::DurationChanged(TimeUnit::FromSeconds(mMediaSourceDuration));
if (mMediaSource && aAction != MSRangeRemovalAction::SKIP) {
mMediaSource->DurationChange(oldDuration, aDuration);
}