author | Eitan Isaacson <eitan@monotonous.org> |
Mon, 30 Nov 2015 18:59:01 -0800 | |
changeset 308958 | 03c6bd7c9aecc4d1c697a1b731bd32580d1fb057 |
parent 308957 | a9f0334501a97f1026aaa651ecbe760762abcef5 |
child 308959 | 86e73c5414d638ce77d4960a260cbeebff659568 |
push id | 5513 |
push user | raliiev@mozilla.com |
push date | Mon, 25 Jan 2016 13:55:34 +0000 |
treeherder | mozilla-beta@5ee97dd05b5c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1225928 |
milestone | 45.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp | file | annotate | diff | comparison | revisions |
--- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp @@ -488,24 +488,36 @@ SpeechDispatcherService::Speak(const nsA // The last three parameters don't matter for an indirect service nsresult rv = aTask->Setup(callback, 0, 0, 0); if (NS_FAILED(rv)) { return rv; } - int msg_id = spd_say(mSpeechdClient, SPD_MESSAGE, NS_ConvertUTF16toUTF8(aText).get()); + if (aText.Length()) { + int msg_id = spd_say( + mSpeechdClient, SPD_MESSAGE, NS_ConvertUTF16toUTF8(aText).get()); + + if (msg_id < 0) { + return NS_ERROR_FAILURE; + } - if (msg_id < 0) { - return NS_ERROR_FAILURE; + mCallbacks.Put(msg_id, callback); + } else { + // Speech dispatcher does not work well with empty strings. + // In that case, don't send empty string to speechd, + // and just emulate a speechd start and end event. + NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<SPDNotificationType>( + callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_BEGIN)); + + NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<SPDNotificationType>( + callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_END)); } - mCallbacks.Put(msg_id, callback); - return NS_OK; } NS_IMETHODIMP SpeechDispatcherService::GetServiceType(SpeechServiceType* aServiceType) { *aServiceType = nsISpeechService::SERVICETYPE_INDIRECT_AUDIO; return NS_OK;