DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_
#define DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_

#include "base/basictypes.h"
#include "nsTArray.h"
#include "nsTArray.h"

namespace mozilla {
namespace dom {

class IMediaController;
class IMediaController;
class MediaControlService;

/**
 * AudioFocusManager is used to assign the audio focus to different requester
 * and decide which requester can own audio focus when audio competing happens.
 * and decide which requester can own audio focus when audio competing happens.
 * When the audio competing happens, the last request would be a winner who can
 * still own the audio focus, and all the other requesters would lose the audio
 * still own the audio focus, and all the other requesters would lose the audio
 * focus. Now MediaController is the onlt requester, it would request the audio
 * focus when it becomes audible and revoke the audio focus when the controller
 * is no longer active.
 */
class AudioFocusManager {
class AudioFocusManager {
 public:
  void RequestAudioFocus(IMediaController* aController);
  void RevokeAudioFocus(IMediaController* aController);


  explicit AudioFocusManager() = default;
  ~AudioFocusManager() = default;

  uint32_t GetAudioFocusNums() const;


 private:
  friend class MediaControlService;
  void ClearFocusControllersIfNeeded();

  nsTArray<RefPtr<IMediaController>> mOwningFocusControllers;
  nsTArray<RefPtr<IMediaController>> mOwningFocusControllers;
};

}  // namespace dom
}  // namespace mozilla


#endif  //  DOM_MEDIA_MEDIACONTROL_AUDIOFOCUSMANAGER_H_