dom/speakermanager/SpeakerManagerService.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:b5b90a7a9b28
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef mozilla_dom_SpeakerManagerService_h__
8 #define mozilla_dom_SpeakerManagerService_h__
9
10 #include "nsAutoPtr.h"
11 #include "nsIObserver.h"
12 #include "nsTArray.h"
13 #include "SpeakerManager.h"
14 #include "nsIAudioManager.h"
15 #include "nsCheapSets.h"
16 #include "nsHashKeys.h"
17
18 namespace mozilla {
19 namespace dom {
20
21 class SpeakerManagerService : public nsIObserver
22 {
23 public:
24 NS_DECL_ISUPPORTS
25 NS_DECL_NSIOBSERVER
26
27 static SpeakerManagerService* GetSpeakerManagerService();
28 virtual void ForceSpeaker(bool aEnable, bool aVisible);
29 virtual bool GetSpeakerStatus();
30 virtual void SetAudioChannelActive(bool aIsActive);
31 // Called by child
32 void ForceSpeaker(bool enable, uint64_t aChildid);
33 // Register the SpeakerManager to service for notify the speakerforcedchange event
34 void RegisterSpeakerManager(SpeakerManager* aSpeakerManager)
35 {
36 mRegisteredSpeakerManagers.AppendElement(aSpeakerManager);
37 }
38 void UnRegisterSpeakerManager(SpeakerManager* aSpeakerManager)
39 {
40 mRegisteredSpeakerManagers.RemoveElement(aSpeakerManager);
41 }
42 /**
43 * Shutdown the singleton.
44 */
45 static void Shutdown();
46
47 protected:
48 SpeakerManagerService();
49
50 virtual ~SpeakerManagerService();
51 // Notify to UA if device speaker status changed
52 virtual void Notify();
53
54 void TuruOnSpeaker(bool aEnable);
55
56 nsTArray<nsRefPtr<SpeakerManager> > mRegisteredSpeakerManagers;
57 // Set for remember all the child speaker status
58 nsCheapSet<nsUint64HashKey> mSpeakerStatusSet;
59 // The Speaker status assign by UA
60 bool mOrgSpeakerStatus;
61
62 bool mVisible;
63 // This is needed for IPC communication between
64 // SpeakerManagerServiceChild and this class.
65 friend class ContentParent;
66 friend class ContentChild;
67 };
68
69 } // namespace dom
70 } // namespace mozilla
71
72 #endif

mercurial