diff --git a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp index e30886c4d215..e1310f1fcba3 100644 --- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp @@ -411,38 +411,24 @@ SpeechDispatcherService::Setup() //mInitialized = true; } -struct VoiceTraverserData -{ - SpeechDispatcherService* mService; - nsSynthVoiceRegistry* mRegistry; -}; - // private methods -static PLDHashOperator -AddVoiceTraverser(const nsAString& aUri, - RefPtr& aVoice, - void* aUserArg) -{ - VoiceTraverserData* data = static_cast(aUserArg); - - // This service can only speak one utterance at a time, se we set - // aQueuesUtterances to true in order to track global state and schedule - // access to this service. - DebugOnly rv = data->mRegistry->AddVoice(data->mService, aUri, - aVoice->mName, aVoice->mLanguage, - aVoice->mName.EqualsLiteral("default"), true); - - NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice"); - - return PL_DHASH_NEXT; -} - void SpeechDispatcherService::RegisterVoices() { - VoiceTraverserData data = { this, nsSynthVoiceRegistry::GetInstance() }; - mVoices.Enumerate(AddVoiceTraverser, &data); + nsSynthVoiceRegistry* registry = nsSynthVoiceRegistry::GetInstance(); + for (auto iter = mVoices.Iter(); !iter.Done(); iter.Next()) { + RefPtr& voice = iter.Data(); + + // This service can only speak one utterance at a time, so we set + // aQueuesUtterances to true in order to track global state and schedule + // access to this service. + DebugOnly rv = + registry->AddVoice(this, iter.Key(), voice->mName, voice->mLanguage, + voice->mName.EqualsLiteral("default"), true); + + NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to add voice"); + } mInitThread->Shutdown(); mInitThread = nullptr;