Bug 915958 - Automatically Finish() MediaQueues, so that each backend doesn't need to remember to do it. r=edwin

This commit is contained in:
Chris Pearce 2013-09-13 14:33:54 +12:00
Родитель a48d09aed2
Коммит 03b4450f4b
10 изменённых файлов: 11 добавлений и 29 удалений

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

@ -912,6 +912,10 @@ void MediaDecoderStateMachine::DecodeLoop()
TimeStamp start = TimeStamp::Now();
videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
decodeTime = TimeStamp::Now() - start;
if (!videoPlaying) {
// Playback ended for this stream, close the sample queue.
mReader->VideoQueue().Finish();
}
}
if (THRESHOLD_FACTOR * DurationToUsecs(decodeTime) > lowAudioThreshold &&
!HasLowUndecodedData())
@ -935,6 +939,10 @@ void MediaDecoderStateMachine::DecodeLoop()
if (!mDidThrottleAudioDecoding) {
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
audioPlaying = mReader->DecodeAudioData();
if (!audioPlaying) {
// Playback ended for this stream, close the sample queue.
mReader->AudioQueue().Finish();
}
}
SendStreamData();

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

@ -214,7 +214,6 @@ DirectShowReader::Finish(HRESULT aStatus)
MOZ_ASSERT(mDecoder->OnDecodeThread(), "Should be on decode thread.");
LOG("DirectShowReader::Finish(0x%x)", aStatus);
mAudioQueue.Finish();
// Notify the filter graph of end of stream.
RefPtr<IMediaEventSink> eventSink;
HRESULT hr = mGraph->QueryInterface(static_cast<IMediaEventSink**>(byRef(eventSink)));

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

@ -77,10 +77,9 @@ public:
private:
// Calls mAudioQueue.Finish(), and notifies the filter graph that playback
// is complete. aStatus is the code to send to the filter graph.
// Always returns false, so that we can just "return Finish()" from
// DecodeAudioData().
// Notifies the filter graph that playback is complete. aStatus is
// the code to send to the filter graph. Always returns false, so
// that we can just "return Finish()" from DecodeAudioData().
bool Finish(HRESULT aStatus);
// DirectShow filter graph, and associated playback and seeking

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

@ -463,7 +463,6 @@ bool GStreamerReader::DecodeAudioData()
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
if (mReachedEos) {
mAudioQueue.Finish();
return false;
}
@ -528,7 +527,6 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
if (mReachedEos) {
mVideoQueue.Finish();
return false;
}
@ -1039,8 +1037,6 @@ void GStreamerReader::Eos()
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
/* Potentially unblock the decode thread in ::DecodeLoop */
mVideoQueue.Finish();
mAudioQueue.Finish();
mon.NotifyAll();
}
}

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

@ -623,7 +623,6 @@ bool OggReader::DecodeAudioData()
} while (packet && codecState->IsHeader(packet));
if (!packet) {
mAudioQueue.Finish();
return false;
}
@ -642,7 +641,6 @@ bool OggReader::DecodeAudioData()
// We've encountered an end of bitstream packet, or we've hit the end of
// file while trying to decode, so inform the audio queue that there'll
// be no more samples.
mAudioQueue.Finish();
return false;
}
@ -840,7 +838,6 @@ bool OggReader::DecodeVideoFrame(bool &aKeyframeSkip,
packet = NextOggPacket(mTheoraState);
} while (packet && mTheoraState->IsHeader(packet));
if (!packet) {
mVideoQueue.Finish();
return false;
}
nsAutoRef<ogg_packet> autoRelease(packet);
@ -864,7 +861,6 @@ bool OggReader::DecodeVideoFrame(bool &aKeyframeSkip,
if (eos) {
// We've encountered an end of bitstream packet. Inform the queue that
// there will be no more frames.
mVideoQueue.Finish();
return false;
}

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

@ -171,7 +171,6 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
frame.mGraphicBuffer = nullptr;
frame.mShouldSkip = false;
if (!mOmxDecoder->ReadVideo(&frame, aTimeThreshold, aKeyframeSkip, doSeek)) {
mVideoQueue.Finish();
return false;
}
doSeek = false;
@ -289,7 +288,6 @@ bool MediaOmxReader::DecodeAudioData()
// Read next frame
MPAPI::AudioFrame frame;
if (!mOmxDecoder->ReadAudio(&frame, mAudioSeekTimeUs)) {
mAudioQueue.Finish();
return false;
}
mAudioSeekTimeUs = -1;

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

@ -148,7 +148,6 @@ bool MediaPluginReader::DecodeVideoFrame(bool &aKeyframeSkip,
mVideoQueue.Push(mLastVideoFrame);
mLastVideoFrame = NULL;
}
mVideoQueue.Finish();
return false;
}
mVideoSeekTimeUs = -1;
@ -292,7 +291,6 @@ bool MediaPluginReader::DecodeAudioData()
// Read next frame
MPAPI::AudioFrame frame;
if (!mPlugin->ReadAudio(mPlugin, &frame, mAudioSeekTimeUs)) {
mAudioQueue.Finish();
return false;
}
mAudioSeekTimeUs = -1;

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

@ -208,7 +208,6 @@ bool WaveReader::DecodeAudioData()
nsAutoArrayPtr<char> dataBuffer(new char[static_cast<size_t>(readSize)]);
if (!ReadAll(dataBuffer, readSize)) {
mAudioQueue.Finish();
return false;
}

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

@ -773,7 +773,6 @@ bool WebMReader::DecodeAudioData()
nsAutoRef<NesteggPacketHolder> holder(NextPacket(AUDIO));
if (!holder) {
AudioQueue().Finish();
return false;
}
@ -792,7 +791,6 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
nsAutoRef<NesteggPacketHolder> holder(NextPacket(VIDEO));
if (!holder) {
VideoQueue().Finish();
return false;
}

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

@ -688,7 +688,6 @@ WMFReader::DecodeAudioData()
if (FAILED(hr)) {
LOG("WMFReader::DecodeAudioData() ReadSample failed with hr=0x%x", hr);
// End the stream.
mAudioQueue.Finish();
return false;
}
@ -703,7 +702,6 @@ WMFReader::DecodeAudioData()
LOG("WMFReader::DecodeAudioData() ReadSample failed with hr=0x%x flags=0x%x",
hr, flags);
// End the stream.
mAudioQueue.Finish();
return false;
}
@ -925,8 +923,6 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
nullptr);
if (FAILED(hr)) {
LOG("WMFReader::DecodeVideoData() ReadSample failed with hr=0x%x", hr);
// End the stream.
mVideoQueue.Finish();
return false;
}
@ -938,7 +934,6 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
if (flags & MF_SOURCE_READERF_ERROR) {
NS_WARNING("WMFReader: Catastrophic failure reading video sample");
// Future ReadSample() calls will fail, so give up and report end of stream.
mVideoQueue.Finish();
return false;
}
@ -950,8 +945,6 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
if (!sample) {
if ((flags & MF_SOURCE_READERF_ENDOFSTREAM)) {
LOG("WMFReader; Null sample after video decode, at end of stream");
// End the stream.
mVideoQueue.Finish();
return false;
}
LOG("WMFReader; Null sample after video decode. Maybe insufficient data...");
@ -966,7 +959,6 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
if (FAILED(hr) ||
FAILED(ConfigureVideoFrameGeometry(mediaType))) {
NS_WARNING("Failed to reconfigure video media type");
mVideoQueue.Finish();
return false;
}
}
@ -997,7 +989,6 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
if ((flags & MF_SOURCE_READERF_ENDOFSTREAM)) {
// End of stream.
mVideoQueue.Finish();
LOG("End of video stream");
return false;
}