Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsPicoService_h |
michael@0 | 8 | #define nsPicoService_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Mutex.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsTArray.h" |
michael@0 | 13 | #include "nsIThread.h" |
michael@0 | 14 | #include "nsISpeechService.h" |
michael@0 | 15 | #include "nsRefPtrHashtable.h" |
michael@0 | 16 | #include "mozilla/StaticPtr.h" |
michael@0 | 17 | #include "mozilla/Monitor.h" |
michael@0 | 18 | |
michael@0 | 19 | namespace mozilla { |
michael@0 | 20 | namespace dom { |
michael@0 | 21 | |
michael@0 | 22 | class PicoVoice; |
michael@0 | 23 | class PicoCallbackRunnable; |
michael@0 | 24 | |
michael@0 | 25 | typedef void* pico_System; |
michael@0 | 26 | typedef void* pico_Resource; |
michael@0 | 27 | typedef void* pico_Engine; |
michael@0 | 28 | |
michael@0 | 29 | class nsPicoService : public nsISpeechService |
michael@0 | 30 | { |
michael@0 | 31 | friend class PicoCallbackRunnable; |
michael@0 | 32 | friend class PicoInitRunnable; |
michael@0 | 33 | |
michael@0 | 34 | public: |
michael@0 | 35 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 36 | NS_DECL_NSISPEECHSERVICE |
michael@0 | 37 | |
michael@0 | 38 | nsPicoService(); |
michael@0 | 39 | |
michael@0 | 40 | virtual ~nsPicoService(); |
michael@0 | 41 | |
michael@0 | 42 | static nsPicoService* GetInstance(); |
michael@0 | 43 | |
michael@0 | 44 | static already_AddRefed<nsPicoService> GetInstanceForService(); |
michael@0 | 45 | |
michael@0 | 46 | static void Shutdown(); |
michael@0 | 47 | |
michael@0 | 48 | private: |
michael@0 | 49 | |
michael@0 | 50 | void Init(); |
michael@0 | 51 | |
michael@0 | 52 | void RegisterVoices(); |
michael@0 | 53 | |
michael@0 | 54 | bool GetVoiceFileLanguage(const nsACString& aFileName, nsAString& aLang); |
michael@0 | 55 | |
michael@0 | 56 | void LoadEngine(PicoVoice* aVoice); |
michael@0 | 57 | |
michael@0 | 58 | void UnloadEngine(); |
michael@0 | 59 | |
michael@0 | 60 | PicoVoice* CurrentVoice(); |
michael@0 | 61 | |
michael@0 | 62 | bool mInitialized; |
michael@0 | 63 | |
michael@0 | 64 | nsCOMPtr<nsIThread> mThread; |
michael@0 | 65 | |
michael@0 | 66 | nsRefPtrHashtable<nsStringHashKey, PicoVoice> mVoices; |
michael@0 | 67 | |
michael@0 | 68 | Monitor mVoicesMonitor; |
michael@0 | 69 | |
michael@0 | 70 | PicoVoice* mCurrentVoice; |
michael@0 | 71 | |
michael@0 | 72 | Atomic<nsISpeechTask*> mCurrentTask; |
michael@0 | 73 | |
michael@0 | 74 | pico_System mPicoSystem; |
michael@0 | 75 | |
michael@0 | 76 | pico_Engine mPicoEngine; |
michael@0 | 77 | |
michael@0 | 78 | pico_Resource mSgResource; |
michael@0 | 79 | |
michael@0 | 80 | pico_Resource mTaResource; |
michael@0 | 81 | |
michael@0 | 82 | nsAutoPtr<uint8_t> mPicoMemArea; |
michael@0 | 83 | |
michael@0 | 84 | static StaticRefPtr<nsPicoService> sSingleton; |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | } // namespace dom |
michael@0 | 88 | } // namespace mozilla |
michael@0 | 89 | |
michael@0 | 90 | #endif |