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
Родитель fa8ccba8c3
Коммит aeeb938a34
3 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)