Esempio n. 1
0
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();
    }

    RefPtr<SpeechSynthesisUtterance> utterance = mUtterance;

    if (mSpeechSynthesis) {
        mSpeechSynthesis->OnEnd(this);
    }

    if (utterance->mState == SpeechSynthesisUtterance::STATE_PENDING) {
        utterance->mState = SpeechSynthesisUtterance::STATE_NONE;
    } else {
        utterance->mState = SpeechSynthesisUtterance::STATE_ENDED;
        utterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("end"),
                                                aCharIndex, aElapsedTime,
                                                EmptyString());
    }

    return NS_OK;
}
Esempio n. 2
0
nsresult
nsSpeechTask::DispatchEndInner(float aElapsedTime, uint32_t aCharIndex)
{
  DestroyAudioChannelAgent();

  if (!mPreCanceled) {
    nsSynthVoiceRegistry::GetInstance()->SpeakNext();
  }

  return DispatchEndImpl(aElapsedTime, aCharIndex);
}
void
AudioDestinationNode::Suspend()
{
  DestroyAudioChannelAgent();
  SendInt32ParameterToStream(DestinationNodeEngine::SUSPENDED, 1);
}