1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * 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 __nsSound_h__ 8 #define __nsSound_h__ 9 10 #include "nsISound.h" 11 #include "nsIObserver.h" 12 #include "nsIStreamLoader.h" 13 #include "nsCOMPtr.h" 14 #include "mozilla/StaticPtr.h" 15 16 class nsIThread; 17 class nsIRunnable; 18 19 class nsSound : public nsISound, 20 public nsIStreamLoaderObserver, 21 public nsIObserver 22 23 { 24 public: 25 nsSound(); 26 static already_AddRefed<nsISound> GetInstance(); 27 28 NS_DECL_ISUPPORTS 29 NS_DECL_NSISOUND 30 NS_DECL_NSISTREAMLOADEROBSERVER 31 NS_DECL_NSIOBSERVER 32 33 private: 34 virtual ~nsSound(); 35 void PurgeLastSound(); 36 37 private: 38 nsresult CreatePlayerThread(); 39 40 nsCOMPtr<nsIThread> mPlayerThread; 41 nsCOMPtr<nsIRunnable> mSoundPlayer; 42 bool mInited; 43 44 static mozilla::StaticRefPtr<nsISound> sInstance; 45 }; 46 47 #endif /* __nsSound_h__ */ 48