michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsPicoService_h michael@0: #define nsPicoService_h michael@0: michael@0: #include "mozilla/Mutex.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIThread.h" michael@0: #include "nsISpeechService.h" michael@0: #include "nsRefPtrHashtable.h" michael@0: #include "mozilla/StaticPtr.h" michael@0: #include "mozilla/Monitor.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class PicoVoice; michael@0: class PicoCallbackRunnable; michael@0: michael@0: typedef void* pico_System; michael@0: typedef void* pico_Resource; michael@0: typedef void* pico_Engine; michael@0: michael@0: class nsPicoService : public nsISpeechService michael@0: { michael@0: friend class PicoCallbackRunnable; michael@0: friend class PicoInitRunnable; michael@0: michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSISPEECHSERVICE michael@0: michael@0: nsPicoService(); michael@0: michael@0: virtual ~nsPicoService(); michael@0: michael@0: static nsPicoService* GetInstance(); michael@0: michael@0: static already_AddRefed GetInstanceForService(); michael@0: michael@0: static void Shutdown(); michael@0: michael@0: private: michael@0: michael@0: void Init(); michael@0: michael@0: void RegisterVoices(); michael@0: michael@0: bool GetVoiceFileLanguage(const nsACString& aFileName, nsAString& aLang); michael@0: michael@0: void LoadEngine(PicoVoice* aVoice); michael@0: michael@0: void UnloadEngine(); michael@0: michael@0: PicoVoice* CurrentVoice(); michael@0: michael@0: bool mInitialized; michael@0: michael@0: nsCOMPtr mThread; michael@0: michael@0: nsRefPtrHashtable mVoices; michael@0: michael@0: Monitor mVoicesMonitor; michael@0: michael@0: PicoVoice* mCurrentVoice; michael@0: michael@0: Atomic mCurrentTask; michael@0: michael@0: pico_System mPicoSystem; michael@0: michael@0: pico_Engine mPicoEngine; michael@0: michael@0: pico_Resource mSgResource; michael@0: michael@0: pico_Resource mTaResource; michael@0: michael@0: nsAutoPtr mPicoMemArea; michael@0: michael@0: static StaticRefPtr sSingleton; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif