Bug 1222697 - Audio Indicator doesn't appear when using Web Speech Synthesis. r?eeejay
Create audio channel agent even if e10s. Dispatch*Inner won't be called from
child process's SpeechSynthesisRequestChild, so it is created at Dispatch*Impl.
MozReview-Commit-ID: 4ZQWE2gPh9g
--- a/dom/media/webspeech/synth/nsSpeechTask.cpp
+++ b/dom/media/webspeech/synth/nsSpeechTask.cpp
@@ -346,18 +346,16 @@ nsSpeechTask::DispatchStart()
}
return DispatchStartInner();
}
nsresult
nsSpeechTask::DispatchStartInner()
{
- CreateAudioChannelAgent();
-
nsSynthVoiceRegistry::GetInstance()->SetIsSpeaking(true);
return DispatchStartImpl();
}
nsresult
nsSpeechTask::DispatchStartImpl()
{
return DispatchStartImpl(mChosenVoiceURI);
@@ -368,16 +366,18 @@ nsSpeechTask::DispatchStartImpl(const ns
{
LOG(LogLevel::Debug, ("nsSpeechTask::DispatchStart"));
MOZ_ASSERT(mUtterance);
if(NS_WARN_IF(!(mUtterance->mState == SpeechSynthesisUtterance::STATE_PENDING))) {
return NS_ERROR_NOT_AVAILABLE;
}
+ CreateAudioChannelAgent();
+
mUtterance->mState = SpeechSynthesisUtterance::STATE_SPEAKING;
mUtterance->mChosenVoiceURI = aUri;
mUtterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("start"), 0, 0,
EmptyString());
return NS_OK;
}
@@ -390,30 +390,30 @@ nsSpeechTask::DispatchEnd(float aElapsed
}
return DispatchEndInner(aElapsedTime, aCharIndex);
}
nsresult
nsSpeechTask::DispatchEndInner(float aElapsedTime, uint32_t aCharIndex)
{
- DestroyAudioChannelAgent();
-
if (!mPreCanceled) {
nsSynthVoiceRegistry::GetInstance()->SpeakNext();
}
return DispatchEndImpl(aElapsedTime, aCharIndex);
}
nsresult
nsSpeechTask::DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex)
{
LOG(LogLevel::Debug, ("nsSpeechTask::DispatchEnd\n"));
+ DestroyAudioChannelAgent();
+
MOZ_ASSERT(mUtterance);
if(NS_WARN_IF(mUtterance->mState == SpeechSynthesisUtterance::STATE_ENDED)) {
return NS_ERROR_NOT_AVAILABLE;
}
// XXX: This should not be here, but it prevents a crash in MSG.
if (mStream) {
mStream->Destroy();