зеркало из https://github.com/mozilla/gecko-dev.git
Back out d28c88e9705d (bug 1128411)
CLOSED TREE
This commit is contained in:
Родитель
6616978c49
Коммит
ab3f3ffe2f
|
@ -401,12 +401,29 @@ static void WriteVideoToMediaStream(MediaStream* aStream,
|
|||
|
||||
void MediaDecoderStateMachine::SendStreamData()
|
||||
{
|
||||
MOZ_ASSERT(OnStateMachineThread(), "Should be on state machine thread");
|
||||
NS_ASSERTION(OnDecodeThread() || OnStateMachineThread(),
|
||||
"Should be on decode thread or state machine thread");
|
||||
AssertCurrentThreadInMonitor();
|
||||
MOZ_ASSERT(!mAudioSink, "Should've been stopped in CallRunStateMachine()");
|
||||
MOZ_ASSERT(mState != DECODER_STATE_DECODING_NONE);
|
||||
|
||||
DecodedStreamData* stream = mDecoder->GetDecodedStream();
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mState == DECODER_STATE_DECODING_METADATA ||
|
||||
mState == DECODER_STATE_DECODING_FIRSTFRAME) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there's still an audio sink alive, then we can't send any stream
|
||||
// data yet since both SendStreamData and the audio sink want to be in
|
||||
// charge of popping the audio queue. We're waiting for the audio sink
|
||||
if (mAudioSink) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t minLastAudioPacketTime = INT64_MAX;
|
||||
bool finished =
|
||||
(!mInfo.HasAudio() || AudioQueue().IsFinished()) &&
|
||||
(!mInfo.HasVideo() || VideoQueue().IsFinished());
|
||||
|
@ -554,6 +571,12 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio(int64_t aAmpleAudioUSecs)
|
|||
|
||||
DecodedStreamData* stream = mDecoder->GetDecodedStream();
|
||||
|
||||
// Since stream is initialized in SendStreamData() which is called when
|
||||
// audio/video samples are received, we need to keep decoding to ensure
|
||||
// the stream is initialized.
|
||||
if (stream && !stream->mStreamInitialized) {
|
||||
return false;
|
||||
}
|
||||
if (stream && stream->mStreamInitialized && !stream->mHaveSentFinishAudio) {
|
||||
if (!stream->mStream->HaveEnoughBuffered(kAudioTrack)) {
|
||||
return false;
|
||||
|
@ -575,6 +598,10 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
|
|||
|
||||
DecodedStreamData* stream = mDecoder->GetDecodedStream();
|
||||
|
||||
if (stream && !stream->mStreamInitialized) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream && stream->mStreamInitialized && !stream->mHaveSentFinishVideo) {
|
||||
if (!stream->mStream->HaveEnoughBuffered(kVideoTrack)) {
|
||||
return false;
|
||||
|
@ -786,10 +813,6 @@ MediaDecoderStateMachine::OnAudioDecoded(AudioData* aAudioSample)
|
|||
if (mIsAudioPrerolling && DonePrerollingAudio()) {
|
||||
StopPrerollingAudio();
|
||||
}
|
||||
// Schedule the state machine to send stream data as soon as possible.
|
||||
if (mAudioCaptured) {
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -846,6 +869,7 @@ MediaDecoderStateMachine::Push(AudioData* aSample)
|
|||
// to reach playing.
|
||||
AudioQueue().Push(aSample);
|
||||
if (mState > DECODER_STATE_DECODING_FIRSTFRAME) {
|
||||
SendStreamData();
|
||||
// The ready state can change when we've decoded data, so update the
|
||||
// ready state, so that DOM events can fire.
|
||||
UpdateReadyState();
|
||||
|
@ -863,6 +887,7 @@ MediaDecoderStateMachine::Push(VideoData* aSample)
|
|||
// to reach playing.
|
||||
VideoQueue().Push(aSample);
|
||||
if (mState > DECODER_STATE_DECODING_FIRSTFRAME) {
|
||||
SendStreamData();
|
||||
// The ready state can change when we've decoded data, so update the
|
||||
// ready state, so that DOM events can fire.
|
||||
UpdateReadyState();
|
||||
|
@ -934,14 +959,11 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
|
|||
case DECODER_STATE_BUFFERING:
|
||||
case DECODER_STATE_DECODING: {
|
||||
CheckIfDecodeComplete();
|
||||
SendStreamData();
|
||||
// The ready state can change when we've decoded data, so update the
|
||||
// ready state, so that DOM events can fire.
|
||||
UpdateReadyState();
|
||||
mDecoder->GetReentrantMonitor().NotifyAll();
|
||||
// Schedule the state machine to notify track ended as soon as possible.
|
||||
if (mAudioCaptured) {
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
return;
|
||||
}
|
||||
case DECODER_STATE_SEEKING: {
|
||||
|
@ -1039,11 +1061,6 @@ MediaDecoderStateMachine::OnVideoDecoded(VideoData* aVideoSample)
|
|||
DECODER_LOG("Slow video decode, set mLowAudioThresholdUsecs=%lld mAmpleAudioThresholdUsecs=%lld",
|
||||
mLowAudioThresholdUsecs, mAmpleAudioThresholdUsecs);
|
||||
}
|
||||
|
||||
// Schedule the state machine to send stream data as soon as possible.
|
||||
if (mAudioCaptured) {
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
return;
|
||||
}
|
||||
case DECODER_STATE_SEEKING: {
|
||||
|
@ -1820,6 +1837,9 @@ void MediaDecoderStateMachine::StopAudioThread()
|
|||
mAudioSink->Shutdown();
|
||||
}
|
||||
mAudioSink = nullptr;
|
||||
// Now that the audio sink is dead, try sending data to our MediaStream(s).
|
||||
// That may have been waiting for the audio thread to stop.
|
||||
SendStreamData();
|
||||
}
|
||||
// Wake up those waiting for audio sink to finish.
|
||||
mDecoder->GetReentrantMonitor().NotifyAll();
|
||||
|
@ -3070,7 +3090,11 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
|||
return;
|
||||
}
|
||||
|
||||
if (mAudioCaptured) {
|
||||
DecodedStreamData* stream = mDecoder->GetDecodedStream();
|
||||
if (stream && !stream->mStreamInitialized) {
|
||||
// Output streams exist but are not initialized yet.
|
||||
// Send the data we already have to allow stream clock to progress and
|
||||
// avoid stalling playback.
|
||||
SendStreamData();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче