dom/system/gonk/AudioChannelManager.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:dd28461e16a7
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef mozilla_dom_system_AudioChannelManager_h
6 #define mozilla_dom_system_AudioChannelManager_h
7
8 #include "mozilla/DOMEventTargetHelper.h"
9 #include "mozilla/Hal.h"
10 #include "mozilla/HalTypes.h"
11 #include "AudioChannelService.h"
12
13 namespace mozilla {
14 namespace hal {
15 class SwitchEvent;
16 typedef Observer<SwitchEvent> SwitchObserver;
17 } // namespace hal
18
19 namespace dom {
20 namespace system {
21
22 class AudioChannelManager MOZ_FINAL
23 : public DOMEventTargetHelper
24 , public hal::SwitchObserver
25 , public nsIDOMEventListener
26 {
27 public:
28 AudioChannelManager();
29 virtual ~AudioChannelManager();
30
31 NS_DECL_ISUPPORTS_INHERITED
32 NS_DECL_NSIDOMEVENTLISTENER
33
34 void Notify(const hal::SwitchEvent& aEvent);
35
36 void Init(nsPIDOMWindow* aWindow);
37
38 /**
39 * WebIDL Interface
40 */
41
42 nsPIDOMWindow* GetParentObject() const
43 {
44 return GetOwner();
45 }
46
47 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
48
49 bool Headphones() const
50 {
51 // Bug 929139 - Remove the assert check for SWITCH_STATE_UNKNOWN.
52 // If any devices (ex: emulator) didn't have the corresponding sys node for
53 // headset switch state then GonkSwitch will report the unknown state.
54 // So it is possible to get unknown state here.
55 return mState != hal::SWITCH_STATE_OFF &&
56 mState != hal::SWITCH_STATE_UNKNOWN;
57 }
58
59 bool SetVolumeControlChannel(const nsAString& aChannel);
60
61 bool GetVolumeControlChannel(nsAString& aChannel);
62
63 IMPL_EVENT_HANDLER(headphoneschange)
64
65 private:
66 void NotifyVolumeControlChannelChanged();
67
68 hal::SwitchState mState;
69 int32_t mVolumeChannel;
70 };
71
72 } // namespace system
73 } // namespace dom
74 } // namespace mozilla
75
76 #endif // mozilla_dom_system_AudioChannelManager_h

mercurial