Bug 812756 - Set AmpleVideoFrames to the minimum to win a race when shutting down OMX.qcom.video.decoder.mpeg4 decoder r=doublec

This commit is contained in:
Edwin Flores 2012-11-28 15:34:53 +13:00
Родитель 234ae7924a
Коммит 4d5425e49e
4 изменённых файлов: 36 добавлений и 6 удалений

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

@ -374,8 +374,8 @@ nsresult StateMachineTracker::RequestCreateDecodeThread(MediaDecoderStateMachine
}
MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
MediaDecoderReader* aReader,
bool aRealTime) :
MediaDecoderReader* aReader,
bool aRealTime) :
mDecoder(aDecoder),
mState(DECODER_STATE_DECODING_METADATA),
mResetPlayStartTime(false),
@ -759,7 +759,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
if (static_cast<uint32_t>(mReader->VideoQueue().GetSize()) < mAmpleVideoFrames * mPlaybackRate) {
if (static_cast<uint32_t>(mReader->VideoQueue().GetSize()) < GetAmpleVideoFrames() * mPlaybackRate) {
return false;
}
@ -795,7 +795,7 @@ void MediaDecoderStateMachine::DecodeLoop()
// Once we've decoded more than videoPumpThreshold video frames, we'll
// no longer be considered to be "pumping video".
const unsigned videoPumpThreshold = mRealTime ? 0 : mAmpleVideoFrames / 2;
const unsigned videoPumpThreshold = mRealTime ? 0 : GetAmpleVideoFrames() / 2;
// After the audio decode fills with more than audioPumpThreshold usecs
// of decoded audio, we'll start to check whether the audio or video decode

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

@ -322,6 +322,9 @@ public:
// shutting down. The decoder monitor must be held while calling this.
bool IsShutdown();
protected:
virtual uint32_t GetAmpleVideoFrames() { return mAmpleVideoFrames; }
private:
class WakeDecoderRunnable : public nsRunnable {
public:

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

@ -6,7 +6,7 @@
#include "MediaOmxDecoder.h"
#include "MediaOmxReader.h"
#include "MediaDecoderStateMachine.h"
#include "MediaOmxStateMachine.h"
namespace mozilla {
@ -22,7 +22,7 @@ MediaDecoder* MediaOmxDecoder::Clone()
MediaDecoderStateMachine* MediaOmxDecoder::CreateStateMachine()
{
return new MediaDecoderStateMachine(this, new MediaOmxReader(this));
return new MediaOmxStateMachine(this, new MediaOmxReader(this));
}
MediaOmxDecoder::~MediaOmxDecoder()

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

@ -0,0 +1,27 @@
#include "MediaDecoder.h"
#include "MediaDecoderReader.h"
#include "MediaDecoderStateMachine.h"
namespace mozilla {
class MediaOmxStateMachine : public MediaDecoderStateMachine
{
public:
MediaOmxStateMachine(MediaDecoder *aDecoder,
MediaDecoderReader *aReader)
: MediaDecoderStateMachine(aDecoder, aReader) { }
protected:
// Due to a bug in the OMX.qcom.video.decoder.mpeg4 decoder, we can't own too
// many video buffers before shutting down the decoder. When we release these
// buffers, they asynchronously signal to OMXCodec that we have returned
// ownership of the buffer.
// If this signal happens while the OMXCodec is shutting down, OMXCodec will
// crash. If the OMXCodec shuts down before all buffers are returned,
// OMXCodec will crash.
// So we need few enough buffers in the queue that all buffers will be
// returned before OMXCodec begins shutdown.
uint32_t GetAmpleVideoFrames() { return 2; }
};
} // namespace mozilla