diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 15:17:21 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 15:17:21 +0000 |
commit | 5537ddf13de7f74c297306aa3f138e8665b73d17 (patch) | |
tree | 153f06e4ba76ec1eb6346728d2bbfcd4031ee443 /chrome/browser/speech/tts_win.cc | |
parent | 938c2f86e8295b2ff599d47f441889418fc828be (diff) | |
download | chromium_src-5537ddf13de7f74c297306aa3f138e8665b73d17.zip chromium_src-5537ddf13de7f74c297306aa3f138e8665b73d17.tar.gz chromium_src-5537ddf13de7f74c297306aa3f138e8665b73d17.tar.bz2 |
Add Pause and Resume to Web TTS & Extension TTS APIs
The web speech spec already includes pause and resume, this
completes the implementation. For parity, this change also adds
support for Pause and Resume to Chrome's TTS extension API
and TTS Engine extension APIs.
BUG=171887
Review URL: https://chromiumcodereview.appspot.com/15108002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/tts_win.cc')
-rw-r--r-- | chrome/browser/speech/tts_win.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/chrome/browser/speech/tts_win.cc b/chrome/browser/speech/tts_win.cc index 06a16f5..bfa2874 100644 --- a/chrome/browser/speech/tts_win.cc +++ b/chrome/browser/speech/tts_win.cc @@ -28,6 +28,10 @@ class TtsPlatformImplWin : public TtsPlatformImpl { virtual bool StopSpeaking(); + virtual void Pause(); + + virtual void Resume(); + virtual bool IsSpeaking(); virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE; @@ -51,6 +55,7 @@ class TtsPlatformImplWin : public TtsPlatformImpl { int prefix_len_; ULONG stream_number_; int char_position_; + bool paused_; friend struct DefaultSingletonTraits<TtsPlatformImplWin>; @@ -125,10 +130,32 @@ bool TtsPlatformImplWin::StopSpeaking() { // Stop speech by speaking the empty string with the purge flag. speech_synthesizer_->Speak(L"", SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); } + if (paused_) { + speech_synthesizer_->Resume(); + paused_ = false; + } } return true; } +void TtsPlatformImplWin::Pause() { + if (speech_synthesizer_.get() && utterance_id_ && !paused_) { + speech_synthesizer_->Pause(); + paused_ = true; + TtsController::GetInstance()->OnTtsEvent( + utterance_id_, TTS_EVENT_PAUSE, char_position_, ""); + } +} + +void TtsPlatformImplWin::Resume() { + if (speech_synthesizer_.get() && utterance_id_ && paused_) { + speech_synthesizer_->Resume(); + paused_ = false; + TtsController::GetInstance()->OnTtsEvent( + utterance_id_, TTS_EVENT_RESUME, char_position_, ""); + } +} + bool TtsPlatformImplWin::IsSpeaking() { if (speech_synthesizer_.get()) { SPVOICESTATUS status; @@ -156,6 +183,8 @@ void TtsPlatformImplWin::GetVoices( voice.events.insert(TTS_EVENT_MARKER); voice.events.insert(TTS_EVENT_WORD); voice.events.insert(TTS_EVENT_SENTENCE); + voice.events.insert(TTS_EVENT_PAUSE); + voice.events.insert(TTS_EVENT_RESUME); } void TtsPlatformImplWin::OnSpeechEvent() { @@ -199,7 +228,8 @@ TtsPlatformImplWin::TtsPlatformImplWin() : utterance_id_(0), prefix_len_(0), stream_number_(0), - char_position_(0) { + char_position_(0), + paused_(false) { speech_synthesizer_.CreateInstance(CLSID_SpVoice); if (speech_synthesizer_.get()) { ULONGLONG event_mask = |