Bug 1238522 - Don't use float type for absmiddle attirubte. r?eeejay draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 13 May 2016 13:23:52 +0900
changeset 366665 b6bb00d274d1a61650958c925061cc00ace761d1
parent 366346 c3f5e6079284a7b7053c41f05d0fe06ff031db03
child 520829 91bde5bcda8cbd2d11e47f6a54e108cc32711ffc
push id18044
push userm_kato@ga2.so-net.ne.jp
push dateFri, 13 May 2016 04:32:52 +0000
reviewerseeejay
bugs1238522
milestone49.0a1
Bug 1238522 - Don't use float type for absmiddle attirubte. r?eeejay SAPI's absmiddle attibute doesn't allow float type. Example, when pitch was 0.75, abmiddle was -2.5. So ISpVoice.Speak() will return error. MozReview-Commit-ID: 2AnrSEDTFkl
dom/media/webspeech/synth/windows/SapiService.cpp
--- a/dom/media/webspeech/synth/windows/SapiService.cpp
+++ b/dom/media/webspeech/synth/windows/SapiService.cpp
@@ -364,17 +364,18 @@ SapiService::Speak(const nsAString& aTex
   long rate = aRate != 0 ? static_cast<long>(10 * log10(aRate) / log10(3)) : 0;
   if (FAILED(spVoice->SetRate(rate))) {
     return NS_ERROR_FAILURE;
   }
 
   // Set the pitch using xml
   nsAutoString xml;
   xml.AssignLiteral("<pitch absmiddle=\"");
-  xml.AppendFloat(aPitch * 10.0f - 10.0f);
+  // absmiddle doesn't allow float type
+  xml.AppendInt(static_cast<int32_t>(aPitch * 10.0f - 10.0f));
   xml.AppendLiteral("\">");
   uint32_t textOffset = xml.Length();
 
   const char16_t* escapedText =
     nsEscapeHTML2(aText.BeginReading(), aText.Length());
   if (!escapedText) {
     return NS_ERROR_OUT_OF_MEMORY;
   }