Bug 1184412. Part 1 - remove dependency on MDSM::OnAudioEndTimeUpdate from DecodedStream. r=roc.

This commit is contained in:
JW Wang 2015-07-17 10:18:04 +08:00
parent 4a90596778
commit dd9cf7606a
3 changed files with 16 additions and 15 deletions

View File

@ -628,13 +628,18 @@ DecodedStream::SendData(double aVolume, bool aIsSameOrigin)
return finished;
}
CheckedInt64
int64_t
DecodedStream::AudioEndTime() const
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
MOZ_ASSERT(mStartTime.isSome(), "Must be called after StartPlayback()");
return mStartTime.ref() +
FramesToUsecs(mData->mAudioFramesWritten, mInfo.mAudio.mRate);
if (mStartTime.isSome() && mInfo.HasAudio()) {
CheckedInt64 t = mStartTime.ref() +
FramesToUsecs(mData->mAudioFramesWritten, mInfo.mAudio.mRate);
if (t.isValid()) {
return t.value();
}
}
return -1;
}
int64_t

View File

@ -111,7 +111,7 @@ public:
void Connect(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
void Remove(MediaStream* aStream);
void SetPlaying(bool aPlaying);
CheckedInt64 AudioEndTime() const;
int64_t AudioEndTime() const;
int64_t GetPosition() const;
bool IsFinished() const;

View File

@ -372,13 +372,6 @@ void MediaDecoderStateMachine::SendStreamData()
bool finished = mDecodedStream->SendData(mVolume, mDecoder->IsSameOriginMedia());
if (mInfo.HasAudio()) {
CheckedInt64 playedUsecs = mDecodedStream->AudioEndTime();
if (playedUsecs.isValid()) {
OnAudioEndTimeUpdate(playedUsecs.value());
}
}
const auto clockTime = GetClock();
while (true) {
const AudioData* a = AudioQueue().PeekFront();
@ -3080,11 +3073,14 @@ MediaDecoderStateMachine::AudioEndTime() const
AssertCurrentThreadInMonitor();
if (mAudioSink) {
return mAudioSink->GetEndTime();
} else if (mAudioCaptured) {
return mDecodedStream->AudioEndTime();
}
// Don't call this after mAudioSink becomes null since we can't distinguish
// "before StartAudioThread" and "after StopAudioThread".
MOZ_ASSERT(mAudioCaptured || !mAudioCompleted);
return mAudioEndTime;
// "before StartAudioThread" and "after StopAudioThread" where mAudioSink
// is null in both cases.
MOZ_ASSERT(!mAudioCompleted);
return -1;
}
void MediaDecoderStateMachine::OnAudioEndTimeUpdate(int64_t aAudioEndTime)