Bug 1128417 - handle playback ended in a consistent way for both file and stream case. r=roc.
This commit is contained in:
@@ -328,14 +328,6 @@ MediaDecoder::DecodedStreamGraphListener::NotifyOutput(MediaStreamGraph* aGraph,
|
|||||||
void
|
void
|
||||||
MediaDecoder::DecodedStreamGraphListener::DoNotifyFinished()
|
MediaDecoder::DecodedStreamGraphListener::DoNotifyFinished()
|
||||||
{
|
{
|
||||||
if (mData && mData->mDecoder) {
|
|
||||||
if (mData->mDecoder->GetState() == PLAY_STATE_PLAYING) {
|
|
||||||
nsCOMPtr<nsIRunnable> event =
|
|
||||||
NS_NewRunnableMethod(mData->mDecoder, &MediaDecoder::PlaybackEnded);
|
|
||||||
NS_DispatchToCurrentThread(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MutexAutoLock lock(mMutex);
|
MutexAutoLock lock(mMutex);
|
||||||
mStreamFinishedOnMainThread = true;
|
mStreamFinishedOnMainThread = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2895,7 +2895,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|||||||
// end of the media, and so that we update the readyState.
|
// end of the media, and so that we update the readyState.
|
||||||
if (VideoQueue().GetSize() > 0 ||
|
if (VideoQueue().GetSize() > 0 ||
|
||||||
(HasAudio() && !mAudioCompleted) ||
|
(HasAudio() && !mAudioCompleted) ||
|
||||||
(mDecoder->GetDecodedStream() && !mDecoder->GetDecodedStream()->IsFinished()))
|
(mAudioCaptured && !mDecoder->GetDecodedStream()->IsFinished()))
|
||||||
{
|
{
|
||||||
AdvanceFrame();
|
AdvanceFrame();
|
||||||
NS_ASSERTION(mDecoder->GetState() != MediaDecoder::PLAY_STATE_PLAYING ||
|
NS_ASSERTION(mDecoder->GetState() != MediaDecoder::PLAY_STATE_PLAYING ||
|
||||||
@@ -2917,10 +2917,8 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
StopAudioThread();
|
StopAudioThread();
|
||||||
// When we're decoding to a stream, the stream's main-thread finish signal
|
|
||||||
// will take care of calling MediaDecoder::PlaybackEnded.
|
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING) {
|
||||||
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING &&
|
|
||||||
!mDecoder->GetDecodedStream()) {
|
|
||||||
int64_t clockTime = std::max(mAudioEndTime, mVideoFrameEndTime);
|
int64_t clockTime = std::max(mAudioEndTime, mVideoFrameEndTime);
|
||||||
clockTime = std::max(int64_t(0), std::max(clockTime, mEndTime));
|
clockTime = std::max(int64_t(0), std::max(clockTime, mEndTime));
|
||||||
UpdatePlaybackPosition(clockTime);
|
UpdatePlaybackPosition(clockTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user