dom/system/gonk/AudioChannelManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/system/gonk/AudioChannelManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_dom_system_AudioChannelManager_h
     1.9 +#define mozilla_dom_system_AudioChannelManager_h
    1.10 +
    1.11 +#include "mozilla/DOMEventTargetHelper.h"
    1.12 +#include "mozilla/Hal.h"
    1.13 +#include "mozilla/HalTypes.h"
    1.14 +#include "AudioChannelService.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace hal {
    1.18 +class SwitchEvent;
    1.19 +typedef Observer<SwitchEvent> SwitchObserver;
    1.20 +} // namespace hal
    1.21 +
    1.22 +namespace dom {
    1.23 +namespace system {
    1.24 +
    1.25 +class AudioChannelManager MOZ_FINAL
    1.26 +  : public DOMEventTargetHelper
    1.27 +  , public hal::SwitchObserver
    1.28 +  , public nsIDOMEventListener
    1.29 +{
    1.30 +public:
    1.31 +  AudioChannelManager();
    1.32 +  virtual ~AudioChannelManager();
    1.33 +
    1.34 +  NS_DECL_ISUPPORTS_INHERITED
    1.35 +  NS_DECL_NSIDOMEVENTLISTENER
    1.36 +
    1.37 +  void Notify(const hal::SwitchEvent& aEvent);
    1.38 +
    1.39 +  void Init(nsPIDOMWindow* aWindow);
    1.40 +
    1.41 +  /**
    1.42 +   * WebIDL Interface
    1.43 +   */
    1.44 +
    1.45 +  nsPIDOMWindow* GetParentObject() const
    1.46 +  {
    1.47 +     return GetOwner();
    1.48 +  }
    1.49 +
    1.50 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.51 +
    1.52 +  bool Headphones() const
    1.53 +  {
    1.54 +    // Bug 929139 - Remove the assert check for SWITCH_STATE_UNKNOWN.
    1.55 +    // If any devices (ex: emulator) didn't have the corresponding sys node for
    1.56 +    // headset switch state then GonkSwitch will report the unknown state.
    1.57 +    // So it is possible to get unknown state here.
    1.58 +    return mState != hal::SWITCH_STATE_OFF &&
    1.59 +           mState != hal::SWITCH_STATE_UNKNOWN;
    1.60 +  }
    1.61 +
    1.62 +  bool SetVolumeControlChannel(const nsAString& aChannel);
    1.63 +
    1.64 +  bool GetVolumeControlChannel(nsAString& aChannel);
    1.65 +
    1.66 +  IMPL_EVENT_HANDLER(headphoneschange)
    1.67 +
    1.68 +private:
    1.69 +  void NotifyVolumeControlChannelChanged();
    1.70 +
    1.71 +  hal::SwitchState mState;
    1.72 +  int32_t mVolumeChannel;
    1.73 +};
    1.74 +
    1.75 +} // namespace system
    1.76 +} // namespace dom
    1.77 +} // namespace mozilla
    1.78 +
    1.79 +#endif // mozilla_dom_system_AudioChannelManager_h

mercurial