Bug 1302350 - part2 : provide an ability to know the media-block-state before connecting to the AudioChannelService.
authorAlastor Wu <alwu@mozilla.com>
Tue, 04 Oct 2016 16:31:16 +0800
changeset 859924 91f66baf6a953e8e5821af8161e7d415aeb1ad9c
parent 859923 a1a677070b4eeb1a15a5ae9fa7a59be5ceed41f1
child 859925 1edda55c1e40fe190483776f5047759fbb18aaf5
push id147813
push useralwu@mozilla.com
push dateTue, 04 Oct 2016 08:34:45 +0000
treeherdertry@9f747740ae7d [default view] [failures only]
bugs1302350
milestone52.0a1
Bug 1302350 - part2 : provide an ability to know the media-block-state before connecting to the AudioChannelService. MozReview-Commit-ID: 1rYx07W3pCN
dom/audiochannel/AudioChannelAgent.cpp
dom/audiochannel/nsIAudioChannelAgent.idl
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -349,8 +349,16 @@ AudioChannelAgent::WindowAudioCaptureCha
   }
 
   MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
          ("AudioChannelAgent, WindowAudioCaptureChanged, this = %p, "
           "capture = %d\n", this, aCapture));
 
   callback->WindowAudioCaptureChanged(aCapture);
 }
+
+NS_IMETHODIMP
+AudioChannelAgent::GetMediaBlocked(bool* aMediaBlocked)
+{
+  *aMediaBlocked = mWindow ?
+    mWindow->GetMediaSuspend() == nsISuspendedTypes::SUSPENDED_BLOCK : false;
+  return NS_OK;
+}
--- a/dom/audiochannel/nsIAudioChannelAgent.idl
+++ b/dom/audiochannel/nsIAudioChannelAgent.idl
@@ -114,16 +114,18 @@ interface nsIAudioChannelAgent : nsISupp
   const long AUDIO_AGENT_STATE_MUTED                = 1;
   const long AUDIO_AGENT_STATE_FADED                = 2;
 
   /**
    * Before init() is called, this returns AUDIO_AGENT_CHANNEL_ERROR.
    */
   readonly attribute long audioChannelType;
 
+  readonly attribute boolean mediaBlocked;
+
   %{C++
   inline int32_t AudioChannelType() {
     int32_t channel;
     return NS_SUCCEEDED(GetAudioChannelType(&channel)) ? channel : AUDIO_AGENT_CHANNEL_ERROR;
   }
   %}
 
   /**