tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SapiService.h (1544B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_SapiService_h
      8 #define mozilla_dom_SapiService_h
      9 
     10 // sapi.h's includes need windows.h on MinGW
     11 // clang-format off
     12 #include <windows.h>
     13 #include <sapi.h>
     14 // clang-format on
     15 
     16 #include "mozilla/StaticPtr.h"
     17 #include "nsIObserver.h"
     18 #include "nsISpeechService.h"
     19 #include "nsRefPtrHashtable.h"
     20 #include "nsTArray.h"
     21 
     22 class nsISynthVoiceRegistry;
     23 
     24 namespace mozilla::dom {
     25 
     26 class SapiCallback;
     27 
     28 class SapiService final : public nsISpeechService, public nsIObserver {
     29 public:
     30  NS_DECL_ISUPPORTS
     31  NS_DECL_NSISPEECHSERVICE
     32  NS_DECL_NSIOBSERVER
     33 
     34  SapiService();
     35  bool Init();
     36 
     37  static SapiService* GetInstance();
     38  static already_AddRefed<SapiService> GetInstanceForService();
     39 
     40  static void __stdcall SpeechEventCallback(WPARAM aWParam, LPARAM aLParam);
     41 
     42 private:
     43  virtual ~SapiService();
     44 
     45  already_AddRefed<ISpVoice> InitSapiInstance();
     46  bool RegisterVoices();
     47  bool RegisterVoices(nsCOMPtr<nsISynthVoiceRegistry>& registry,
     48                      const WCHAR* categoryId);
     49 
     50  nsRefPtrHashtable<nsStringHashKey, ISpObjectToken> mVoices;
     51  nsTArray<RefPtr<SapiCallback>> mCallbacks;
     52 
     53  bool mInitialized;
     54 
     55  static StaticRefPtr<SapiService> sSingleton;
     56 };
     57 
     58 }  // namespace mozilla::dom
     59 
     60 #endif