Bug 1270110 - Bail on unsupported libspeechd versions. r=smaug draft
authorEitan Isaacson <eitan@monotonous.org>
Fri, 15 Jul 2016 12:50:28 -0700
changeset 389217 3b4efab160e08ee4905fcf3d5c0f342d4aaf589a
parent 387466 da8a989f65d1f4883f174bf07dff099104e7b3d4
child 389218 ced91ba107515007f40438eb2bdf788bcf3e0525
push id23316
push userbmo:eitan@monotonous.org
push dateMon, 18 Jul 2016 18:33:00 +0000
reviewerssmaug
bugs1270110
milestone50.0a1
Bug 1270110 - Bail on unsupported libspeechd versions. r=smaug libspeechd does not have a version getter function, so we need to look for a recent API addition to know we are on a newer version. MozReview-Commit-ID: FpXwGYMxxDB
dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp
--- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp
+++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp
@@ -339,16 +339,23 @@ SpeechDispatcherService::Setup()
 
   speechdLib = PR_LoadLibrary("libspeechd.so.2");
 
   if (!speechdLib) {
     NS_WARNING("Failed to load speechd library");
     return;
   }
 
+  if (!PR_FindFunctionSymbol(speechdLib, "spd_get_volume")) {
+    // There is no version getter function, so we rely on a symbol that was
+    // introduced in release 0.8.2 in order to check for ABI compatibility.
+    NS_WARNING("Unsupported version of speechd detected");
+    return;
+  }
+
   for (uint32_t i = 0; i < ArrayLength(kSpeechDispatcherSymbols); i++) {
     *kSpeechDispatcherSymbols[i].function =
       PR_FindFunctionSymbol(speechdLib, kSpeechDispatcherSymbols[i].functionName);
 
     if (!*kSpeechDispatcherSymbols[i].function) {
       NS_WARNING(nsPrintfCString("Failed to find speechd symbol for'%s'",
                                  kSpeechDispatcherSymbols[i].functionName).get());
       return;