1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webspeech/synth/pico/nsPicoService.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsPicoService_h 1.11 +#define nsPicoService_h 1.12 + 1.13 +#include "mozilla/Mutex.h" 1.14 +#include "nsAutoPtr.h" 1.15 +#include "nsTArray.h" 1.16 +#include "nsIThread.h" 1.17 +#include "nsISpeechService.h" 1.18 +#include "nsRefPtrHashtable.h" 1.19 +#include "mozilla/StaticPtr.h" 1.20 +#include "mozilla/Monitor.h" 1.21 + 1.22 +namespace mozilla { 1.23 +namespace dom { 1.24 + 1.25 +class PicoVoice; 1.26 +class PicoCallbackRunnable; 1.27 + 1.28 +typedef void* pico_System; 1.29 +typedef void* pico_Resource; 1.30 +typedef void* pico_Engine; 1.31 + 1.32 +class nsPicoService : public nsISpeechService 1.33 +{ 1.34 + friend class PicoCallbackRunnable; 1.35 + friend class PicoInitRunnable; 1.36 + 1.37 +public: 1.38 + NS_DECL_THREADSAFE_ISUPPORTS 1.39 + NS_DECL_NSISPEECHSERVICE 1.40 + 1.41 + nsPicoService(); 1.42 + 1.43 + virtual ~nsPicoService(); 1.44 + 1.45 + static nsPicoService* GetInstance(); 1.46 + 1.47 + static already_AddRefed<nsPicoService> GetInstanceForService(); 1.48 + 1.49 + static void Shutdown(); 1.50 + 1.51 +private: 1.52 + 1.53 + void Init(); 1.54 + 1.55 + void RegisterVoices(); 1.56 + 1.57 + bool GetVoiceFileLanguage(const nsACString& aFileName, nsAString& aLang); 1.58 + 1.59 + void LoadEngine(PicoVoice* aVoice); 1.60 + 1.61 + void UnloadEngine(); 1.62 + 1.63 + PicoVoice* CurrentVoice(); 1.64 + 1.65 + bool mInitialized; 1.66 + 1.67 + nsCOMPtr<nsIThread> mThread; 1.68 + 1.69 + nsRefPtrHashtable<nsStringHashKey, PicoVoice> mVoices; 1.70 + 1.71 + Monitor mVoicesMonitor; 1.72 + 1.73 + PicoVoice* mCurrentVoice; 1.74 + 1.75 + Atomic<nsISpeechTask*> mCurrentTask; 1.76 + 1.77 + pico_System mPicoSystem; 1.78 + 1.79 + pico_Engine mPicoEngine; 1.80 + 1.81 + pico_Resource mSgResource; 1.82 + 1.83 + pico_Resource mTaResource; 1.84 + 1.85 + nsAutoPtr<uint8_t> mPicoMemArea; 1.86 + 1.87 + static StaticRefPtr<nsPicoService> sSingleton; 1.88 +}; 1.89 + 1.90 +} // namespace dom 1.91 +} // namespace mozilla 1.92 + 1.93 +#endif