diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp')
-rw-r--r-- | dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp new file mode 100644 index 000000000..d1cb8bf0e --- /dev/null +++ b/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp @@ -0,0 +1,213 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "SpeechSynthesisChild.h" +#include "nsSynthVoiceRegistry.h" + +namespace mozilla { +namespace dom { + +SpeechSynthesisChild::SpeechSynthesisChild() +{ + MOZ_COUNT_CTOR(SpeechSynthesisChild); +} + +SpeechSynthesisChild::~SpeechSynthesisChild() +{ + MOZ_COUNT_DTOR(SpeechSynthesisChild); +} + +bool +SpeechSynthesisChild::RecvVoiceAdded(const RemoteVoice& aVoice) +{ + nsSynthVoiceRegistry::RecvAddVoice(aVoice); + return true; +} + +bool +SpeechSynthesisChild::RecvVoiceRemoved(const nsString& aUri) +{ + nsSynthVoiceRegistry::RecvRemoveVoice(aUri); + return true; +} + +bool +SpeechSynthesisChild::RecvSetDefaultVoice(const nsString& aUri, + const bool& aIsDefault) +{ + nsSynthVoiceRegistry::RecvSetDefaultVoice(aUri, aIsDefault); + return true; +} + +bool +SpeechSynthesisChild::RecvIsSpeakingChanged(const bool& aIsSpeaking) +{ + nsSynthVoiceRegistry::RecvIsSpeakingChanged(aIsSpeaking); + return true; +} + +bool +SpeechSynthesisChild::RecvNotifyVoicesChanged() +{ + nsSynthVoiceRegistry::RecvNotifyVoicesChanged(); + return true; +} + +PSpeechSynthesisRequestChild* +SpeechSynthesisChild::AllocPSpeechSynthesisRequestChild(const nsString& aText, + const nsString& aLang, + const nsString& aUri, + const float& aVolume, + const float& aRate, + const float& aPitch) +{ + MOZ_CRASH("Caller is supposed to manually construct a request!"); +} + +bool +SpeechSynthesisChild::DeallocPSpeechSynthesisRequestChild(PSpeechSynthesisRequestChild* aActor) +{ + delete aActor; + return true; +} + +// SpeechSynthesisRequestChild + +SpeechSynthesisRequestChild::SpeechSynthesisRequestChild(SpeechTaskChild* aTask) + : mTask(aTask) +{ + mTask->mActor = this; + MOZ_COUNT_CTOR(SpeechSynthesisRequestChild); +} + +SpeechSynthesisRequestChild::~SpeechSynthesisRequestChild() +{ + MOZ_COUNT_DTOR(SpeechSynthesisRequestChild); +} + +bool +SpeechSynthesisRequestChild::RecvOnStart(const nsString& aUri) +{ + mTask->DispatchStartImpl(aUri); + return true; +} + +bool +SpeechSynthesisRequestChild::RecvOnEnd(const bool& aIsError, + const float& aElapsedTime, + const uint32_t& aCharIndex) +{ + SpeechSynthesisRequestChild* actor = mTask->mActor; + mTask->mActor = nullptr; + + if (aIsError) { + mTask->DispatchErrorImpl(aElapsedTime, aCharIndex); + } else { + mTask->DispatchEndImpl(aElapsedTime, aCharIndex); + } + + actor->Send__delete__(actor); + + return true; +} + +bool +SpeechSynthesisRequestChild::RecvOnPause(const float& aElapsedTime, + const uint32_t& aCharIndex) +{ + mTask->DispatchPauseImpl(aElapsedTime, aCharIndex); + return true; +} + +bool +SpeechSynthesisRequestChild::RecvOnResume(const float& aElapsedTime, + const uint32_t& aCharIndex) +{ + mTask->DispatchResumeImpl(aElapsedTime, aCharIndex); + return true; +} + +bool +SpeechSynthesisRequestChild::RecvOnBoundary(const nsString& aName, + const float& aElapsedTime, + const uint32_t& aCharIndex) +{ + mTask->DispatchBoundaryImpl(aName, aElapsedTime, aCharIndex); + return true; +} + +bool +SpeechSynthesisRequestChild::RecvOnMark(const nsString& aName, + const float& aElapsedTime, + const uint32_t& aCharIndex) +{ + mTask->DispatchMarkImpl(aName, aElapsedTime, aCharIndex); + return true; +} + +// SpeechTaskChild + +SpeechTaskChild::SpeechTaskChild(SpeechSynthesisUtterance* aUtterance) + : nsSpeechTask(aUtterance) +{ +} + +NS_IMETHODIMP +SpeechTaskChild::Setup(nsISpeechTaskCallback* aCallback, + uint32_t aChannels, uint32_t aRate, uint8_t argc) +{ + MOZ_CRASH("Should never be called from child"); +} + +NS_IMETHODIMP +SpeechTaskChild::SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks, + JSContext* aCx) +{ + MOZ_CRASH("Should never be called from child"); +} + +NS_IMETHODIMP +SpeechTaskChild::SendAudioNative(int16_t* aData, uint32_t aDataLen) +{ + MOZ_CRASH("Should never be called from child"); +} + +void +SpeechTaskChild::Pause() +{ + MOZ_ASSERT(mActor); + mActor->SendPause(); +} + +void +SpeechTaskChild::Resume() +{ + MOZ_ASSERT(mActor); + mActor->SendResume(); +} + +void +SpeechTaskChild::Cancel() +{ + MOZ_ASSERT(mActor); + mActor->SendCancel(); +} + +void +SpeechTaskChild::ForceEnd() +{ + MOZ_ASSERT(mActor); + mActor->SendForceEnd(); +} + +void +SpeechTaskChild::SetAudioOutputVolume(float aVolume) +{ + if (mActor) { + mActor->SendSetAudioOutputVolume(aVolume); + } +} + +} // namespace dom +} // namespace mozilla |