Bug 902145 - Ignore all speech events while aborting. r=smaug

This commit is contained in:
Guilherme Gonçalves 2013-09-10 13:12:54 -04:00
parent b7c52c11e1
commit dfb2add017
2 changed files with 12 additions and 8 deletions

View File

@ -138,6 +138,11 @@ SpeechRecognition::ProcessEvent(SpeechEvent* aEvent)
GetName(aEvent),
GetName(mCurrentState));
if (mAborted && aEvent->mType != EVENT_ABORT) {
// ignore all events while aborting
return;
}
Transition(aEvent);
}
@ -297,9 +302,6 @@ SpeechRecognition::Transition(SpeechEvent* aEvent)
MOZ_CRASH("Invalid event EVENT_COUNT");
}
break;
case STATE_ABORTING:
DoNothing(aEvent);
break;
case STATE_COUNT:
MOZ_CRASH("Invalid state STATE_COUNT");
}
@ -377,6 +379,7 @@ SpeechRecognition::Reset()
mEstimationSamples = 0;
mBufferedSamples = 0;
mSpeechDetectionTimer->Cancel();
mAborted = false;
}
void
@ -490,9 +493,6 @@ SpeechRecognition::AbortSilently(SpeechEvent* aEvent)
{
bool stopRecording = StateBetween(STATE_ESTIMATING, STATE_RECOGNIZING);
// prevent reentrancy from DOM events
SetState(STATE_ABORTING);
if (mRecognitionService) {
mRecognitionService->Abort();
}
@ -734,6 +734,11 @@ SpeechRecognition::Stop()
void
SpeechRecognition::Abort()
{
if (mAborted) {
return;
}
mAborted = true;
nsRefPtr<SpeechEvent> event = new SpeechEvent(this, EVENT_ABORT);
NS_DispatchToMainThread(event);
}
@ -891,7 +896,6 @@ SpeechRecognition::GetName(FSMState aId)
"STATE_WAITING_FOR_SPEECH",
"STATE_RECOGNIZING",
"STATE_WAITING_FOR_RESULT",
"STATE_ABORTING"
};
MOZ_ASSERT(aId < STATE_COUNT);

View File

@ -170,7 +170,6 @@ private:
STATE_WAITING_FOR_SPEECH,
STATE_RECOGNIZING,
STATE_WAITING_FOR_RESULT,
STATE_ABORTING,
STATE_COUNT
};
@ -260,6 +259,7 @@ private:
uint32_t mBufferedSamples;
nsCOMPtr<nsITimer> mSpeechDetectionTimer;
bool mAborted;
void ProcessTestEventRequest(nsISupports* aSubject, const nsAString& aEventName);