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
--- 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;
}