Bug 799344 - Remove nsBuiltinDecoder::GetDecodeState(), so that nsBuiltinDecoder doesn't need to know about nsDecoderStateMachine::State. r=roc

This commit is contained in:
Chris Pearce 2012-11-07 11:33:01 +13:00
parent 21e2fae3bd
commit 9ee26e5a65
9 changed files with 24 additions and 27 deletions

View File

@ -346,14 +346,6 @@ nsDASHRepDecoder::GetReentrantMonitor()
return mMainDecoder->GetReentrantMonitor();
}
nsDecoderStateMachine::State
nsDASHRepDecoder::GetDecodeState()
{
// XXX SHUTDOWN might not be an appropriate error.
return (mMainDecoder ? mMainDecoder->GetDecodeState()
: nsDecoderStateMachine::DECODER_STATE_SHUTDOWN);
}
mozilla::layers::ImageContainer*
nsDASHRepDecoder::GetImageContainer()
{

View File

@ -135,10 +135,6 @@ public:
// Returns main decoder's monitor for synchronised access.
ReentrantMonitor& GetReentrantMonitor();
// Return the current decode state, according to the main decoder. The
// decoder monitor must be obtained before calling this.
nsDecoderStateMachine::State GetDecodeState();
// Called on the decode thread from nsWebMReader.
ImageContainer* GetImageContainer();

View File

@ -240,6 +240,10 @@ public:
virtual void Shutdown() = 0;
// True if the state machine has shutdown, or is in the process of
// shutting down. The decoder monitor must be obtained before calling this.
virtual bool IsShutdown() = 0;
// Called from the main thread to get the duration. The decoder monitor
// must be obtained before calling this. It is in units of microseconds.
virtual int64_t GetDuration() = 0;
@ -699,10 +703,6 @@ public:
// Provide access to the state machine object
nsDecoderStateMachine* GetStateMachine() { return mDecoderStateMachine; }
// Return the current decode state. The decoder monitor must be
// obtained before calling this.
nsDecoderStateMachine::State GetDecodeState() { return mDecoderStateMachine->GetState(); }
// Drop reference to state machine. Only called during shutdown dance.
virtual void ReleaseStateMachine() { mDecoderStateMachine = nullptr; }

View File

@ -389,7 +389,7 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(int64_t aTarget)
eof = !DecodeVideoFrame(skip, 0);
{
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
return NS_ERROR_FAILURE;
}
}
@ -416,7 +416,7 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(int64_t aTarget)
}
{
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
return NS_ERROR_FAILURE;
}
}
@ -431,7 +431,7 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(int64_t aTarget)
eof = !DecodeAudioData();
{
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
return NS_ERROR_FAILURE;
}
}

View File

@ -486,8 +486,7 @@ public:
while (!eof && aQueue.GetSize() == 0) {
{
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState()
== nsDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
return nullptr;
}
}

View File

@ -2613,3 +2613,10 @@ void nsBuiltinDecoderStateMachine::NotifyAudioAvailableListener()
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mEventManager.NotifyAudioAvailableListener();
}
bool nsBuiltinDecoderStateMachine::IsShutdown()
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return GetState() == DECODER_STATE_SHUTDOWN;
}

View File

@ -116,9 +116,9 @@ public:
// nsDecoderStateMachine interface
virtual nsresult Init(nsDecoderStateMachine* aCloneDonor);
State GetState()
{
{
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mState;
return mState;
}
virtual void SetVolume(double aVolume);
virtual void SetAudioCaptured(bool aCapture);
@ -264,6 +264,10 @@ public:
bool HaveEnoughDecodedAudio(int64_t aAmpleAudioUSecs);
bool HaveEnoughDecodedVideo();
// Returns true if the state machine has shutdown or is in the process of
// shutting down. The decoder monitor must be held while calling this.
bool IsShutdown() MOZ_OVERRIDE;
protected:
class WakeDecoderRunnable : public nsRunnable {
public:

View File

@ -1106,7 +1106,7 @@ nsOggReader::IndexedSeekResult nsOggReader::SeekToKeyframeUsingIndex(int64_t aTa
// Couldn't insert page into the ogg resource, or somehow the resource
// is no longer active.
return RollbackIndexedSeek(tell);
}
}
mPageOffset = keyframe.mKeyPoint.mOffset + page.header_len + page.body_len;
return SEEK_OK;
}
@ -1136,7 +1136,7 @@ nsresult nsOggReader::SeekInBufferedRange(int64_t aTarget,
eof = !DecodeVideoFrame(skip, 0);
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
return NS_ERROR_FAILURE;
}
}

View File

@ -258,8 +258,7 @@ nsresult nsRawReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
{
mozilla::ReentrantMonitorAutoEnter autoMonitor(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() ==
nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
if (mDecoder->GetStateMachine()->IsShutdown()) {
mCurrentFrame = frame;
return NS_ERROR_FAILURE;
}