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 file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_system_AudioChannelManager_h michael@0: #define mozilla_dom_system_AudioChannelManager_h michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/Hal.h" michael@0: #include "mozilla/HalTypes.h" michael@0: #include "AudioChannelService.h" michael@0: michael@0: namespace mozilla { michael@0: namespace hal { michael@0: class SwitchEvent; michael@0: typedef Observer SwitchObserver; michael@0: } // namespace hal michael@0: michael@0: namespace dom { michael@0: namespace system { michael@0: michael@0: class AudioChannelManager MOZ_FINAL michael@0: : public DOMEventTargetHelper michael@0: , public hal::SwitchObserver michael@0: , public nsIDOMEventListener michael@0: { michael@0: public: michael@0: AudioChannelManager(); michael@0: virtual ~AudioChannelManager(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: michael@0: void Notify(const hal::SwitchEvent& aEvent); michael@0: michael@0: void Init(nsPIDOMWindow* aWindow); michael@0: michael@0: /** michael@0: * WebIDL Interface michael@0: */ michael@0: michael@0: nsPIDOMWindow* GetParentObject() const michael@0: { michael@0: return GetOwner(); michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: bool Headphones() const michael@0: { michael@0: // Bug 929139 - Remove the assert check for SWITCH_STATE_UNKNOWN. michael@0: // If any devices (ex: emulator) didn't have the corresponding sys node for michael@0: // headset switch state then GonkSwitch will report the unknown state. michael@0: // So it is possible to get unknown state here. michael@0: return mState != hal::SWITCH_STATE_OFF && michael@0: mState != hal::SWITCH_STATE_UNKNOWN; michael@0: } michael@0: michael@0: bool SetVolumeControlChannel(const nsAString& aChannel); michael@0: michael@0: bool GetVolumeControlChannel(nsAString& aChannel); michael@0: michael@0: IMPL_EVENT_HANDLER(headphoneschange) michael@0: michael@0: private: michael@0: void NotifyVolumeControlChannelChanged(); michael@0: michael@0: hal::SwitchState mState; michael@0: int32_t mVolumeChannel; michael@0: }; michael@0: michael@0: } // namespace system michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_system_AudioChannelManager_h