Bug 1142933 - New audio channel type for system usages. r=baku.
authorAlastor Wu <alwu@mozilla.com>
Mon, 16 Mar 2015 12:01:50 +0800
changeset 511289 b032cff9264591cfc16fd98bfdef4d6a36b264e4
parent 510838 8e5c888d0d896f06b90f5a6a68e84652aea85eb6
child 511290 29c65c3a7e97eb137d37285082d3ad16e676a055
push id79450
push useralwu@mozilla.com
push dateWed, 22 Jul 2015 11:23:23 +0000
treeherdertry@29c65c3a7e97 [default view] [failures only]
reviewersbaku
bugs1142933
milestone42.0a1
Bug 1142933 - New audio channel type for system usages. r=baku.
dom/apps/PermissionsTable.jsm
dom/audiochannel/AudioChannelAgent.cpp
dom/audiochannel/nsIAudioChannelAgent.idl
dom/media/CubebUtils.cpp
dom/system/gonk/AudioManager.cpp
dom/webidl/AudioChannel.webidl
--- a/dom/apps/PermissionsTable.jsm
+++ b/dom/apps/PermissionsTable.jsm
@@ -343,16 +343,22 @@ this.PermissionsTable =  { geolocation: 
                              certified: ALLOW_ACTION
                            },
                            "audio-channel-alarm": {
                              app: DENY_ACTION,
                              trusted: DENY_ACTION,
                              privileged: ALLOW_ACTION,
                              certified: ALLOW_ACTION
                            },
+                           "audio-channel-system": {
+                             app: DENY_ACTION,
+                             trusted: DENY_ACTION,
+                             privileged: ALLOW_ACTION,
+                             certified: ALLOW_ACTION
+                           },
                            "audio-channel-telephony": {
                              app: DENY_ACTION,
                              trusted: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "moz-audio-channel-telephony": {
                              app: DENY_ACTION,
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -88,16 +88,17 @@ AudioChannelAgent::InitInternal(nsIDOMWi
   // We syncd the enum of channel type between nsIAudioChannelAgent.idl and
   // AudioChannelBinding.h the same.
   MOZ_ASSERT(int(AUDIO_AGENT_CHANNEL_NORMAL) == int(AudioChannel::Normal) &&
              int(AUDIO_AGENT_CHANNEL_CONTENT) == int(AudioChannel::Content) &&
              int(AUDIO_AGENT_CHANNEL_NOTIFICATION) == int(AudioChannel::Notification) &&
              int(AUDIO_AGENT_CHANNEL_ALARM) == int(AudioChannel::Alarm) &&
              int(AUDIO_AGENT_CHANNEL_TELEPHONY) == int(AudioChannel::Telephony) &&
              int(AUDIO_AGENT_CHANNEL_RINGER) == int(AudioChannel::Ringer) &&
+             int(AUDIO_AGENT_CHANNEL_SYSTEM) == int(AudioChannel::System) &&
              int(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) == int(AudioChannel::Publicnotification),
              "Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelBinding.h");
 
   if (mAudioChannelType != AUDIO_AGENT_CHANNEL_ERROR ||
       aChannelType > AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION ||
       aChannelType < AUDIO_AGENT_CHANNEL_NORMAL) {
     return NS_ERROR_FAILURE;
   }
--- a/dom/audiochannel/nsIAudioChannelAgent.idl
+++ b/dom/audiochannel/nsIAudioChannelAgent.idl
@@ -34,16 +34,17 @@ interface nsIAudioChannelAgent : nsISupp
 {
   const long AUDIO_AGENT_CHANNEL_NORMAL             = 0;
   const long AUDIO_AGENT_CHANNEL_CONTENT            = 1;
   const long AUDIO_AGENT_CHANNEL_NOTIFICATION       = 2;
   const long AUDIO_AGENT_CHANNEL_ALARM              = 3;
   const long AUDIO_AGENT_CHANNEL_TELEPHONY          = 4;
   const long AUDIO_AGENT_CHANNEL_RINGER             = 5;
   const long AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION = 6;
+  const long AUDIO_AGENT_CHANNEL_SYSTEM             = 7;
 
   const long AUDIO_AGENT_CHANNEL_ERROR              = 1000;
 
   const long AUDIO_AGENT_STATE_NORMAL               = 0;
   const long AUDIO_AGENT_STATE_MUTED                = 1;
   const long AUDIO_AGENT_STATE_FADED                = 2;
 
   /**
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -176,16 +176,18 @@ cubeb_stream_type ConvertChannelToCubebT
     case dom::AudioChannel::Notification:
       return CUBEB_STREAM_TYPE_NOTIFICATION;
     case dom::AudioChannel::Alarm:
       return CUBEB_STREAM_TYPE_ALARM;
     case dom::AudioChannel::Telephony:
       return CUBEB_STREAM_TYPE_VOICE_CALL;
     case dom::AudioChannel::Ringer:
       return CUBEB_STREAM_TYPE_RING;
+    case dom::AudioChannel::System:
+      return CUBEB_STREAM_TYPE_SYSTEM;
     case dom::AudioChannel::Publicnotification:
       return CUBEB_STREAM_TYPE_SYSTEM_ENFORCED;
     default:
       NS_ERROR("The value of AudioChannel is invalid");
       return CUBEB_STREAM_TYPE_MAX;
   }
 }
 #endif
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -778,27 +778,27 @@ AudioManager::SetVolumeByCategory(uint32
       // sync FMRadio's volume with content channel.
       if (IsDeviceOn(AUDIO_DEVICE_OUT_FM)) {
         status = SetStreamVolumeIndex(AUDIO_STREAM_FM, aIndex);
         if (NS_WARN_IF(NS_FAILED(status))) {
           return status;
         }
       }
       status = SetStreamVolumeIndex(AUDIO_STREAM_MUSIC, aIndex);
-      if (NS_WARN_IF(NS_FAILED(status))) {
-        return status;
-      }
-      status = SetStreamVolumeIndex(AUDIO_STREAM_SYSTEM, aIndex);
       break;
     case VOLUME_NOTIFICATION:
       status = SetStreamVolumeIndex(AUDIO_STREAM_NOTIFICATION, aIndex);
       if (NS_WARN_IF(NS_FAILED(status))) {
         return status;
       }
       status = SetStreamVolumeIndex(AUDIO_STREAM_RING, aIndex);
+      if (NS_WARN_IF(NS_FAILED(status))) {
+        return status;
+      }
+      status = SetStreamVolumeIndex(AUDIO_STREAM_SYSTEM, aIndex);
       break;
     case VOLUME_ALARM:
       status = SetStreamVolumeIndex(AUDIO_STREAM_ALARM, aIndex);
       break;
     case VOLUME_TELEPHONY:
       status = SetStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, aIndex);
     case VOLUME_BLUETOOTH_SCO:
       status = SetStreamVolumeIndex(AUDIO_STREAM_BLUETOOTH_SCO, aIndex);
@@ -809,22 +809,22 @@ AudioManager::SetVolumeByCategory(uint32
   return status;
 }
 
 uint32_t
 AudioManager::GetVolumeByCategory(uint32_t aCategory) const
 {
   switch (static_cast<AudioVolumeCategories>(aCategory)) {
     case VOLUME_MEDIA:
-      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
-                 mCurrentStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
       return mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
     case VOLUME_NOTIFICATION:
       MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
                  mCurrentStreamVolumeTbl[AUDIO_STREAM_RING]);
+      MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
+                 mCurrentStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
       return mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
     case VOLUME_ALARM:
       return mCurrentStreamVolumeTbl[AUDIO_STREAM_ALARM];
     case VOLUME_TELEPHONY:
       return mCurrentStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
     case VOLUME_BLUETOOTH_SCO:
       return mCurrentStreamVolumeTbl[AUDIO_STREAM_BLUETOOTH_SCO];
     default:
@@ -833,22 +833,22 @@ AudioManager::GetVolumeByCategory(uint32
   }
 }
 
 uint32_t
 AudioManager::GetMaxVolumeByCategory(uint32_t aCategory) const
 {
   switch (static_cast<AudioVolumeCategories>(aCategory)) {
     case VOLUME_MEDIA:
-      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
-                 sMaxStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
       return sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC];
     case VOLUME_NOTIFICATION:
       MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
                  sMaxStreamVolumeTbl[AUDIO_STREAM_RING]);
+      MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
+                 sMaxStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
       return sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
     case VOLUME_ALARM:
       return sMaxStreamVolumeTbl[AUDIO_STREAM_ALARM];
     case VOLUME_TELEPHONY:
       return sMaxStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
     case VOLUME_BLUETOOTH_SCO:
       return sMaxStreamVolumeTbl[AUDIO_STREAM_BLUETOOTH_SCO];
     default:
@@ -866,16 +866,17 @@ AudioManager::SetAudioChannelVolume(uint
   switch (static_cast<AudioChannel>(aChannel)) {
     case AudioChannel::Normal:
     case AudioChannel::Content:
       status = SetVolumeByCategory(VOLUME_MEDIA, aIndex);
       break;
     case AudioChannel::Notification:
     case AudioChannel::Ringer:
     case AudioChannel::Publicnotification:
+    case AudioChannel::System:
       status = SetVolumeByCategory(VOLUME_NOTIFICATION, aIndex);
       break;
     case AudioChannel::Alarm:
       status = SetVolumeByCategory(VOLUME_ALARM, aIndex);
       break;
     case AudioChannel::Telephony:
       status = SetVolumeByCategory(category, aIndex);
       break;
@@ -896,16 +897,17 @@ AudioManager::GetAudioChannelVolume(uint
   switch (static_cast<AudioChannel>(aChannel)) {
     case AudioChannel::Normal:
     case AudioChannel::Content:
       *aIndex = GetVolumeByCategory(VOLUME_MEDIA);
       break;
     case AudioChannel::Notification:
     case AudioChannel::Ringer:
     case AudioChannel::Publicnotification:
+    case AudioChannel::System:
       *aIndex = GetVolumeByCategory(VOLUME_NOTIFICATION);
       break;
     case AudioChannel::Alarm:
       *aIndex = GetVolumeByCategory(VOLUME_ALARM);
       break;
     case AudioChannel::Telephony:
       *aIndex = GetVolumeByCategory(category);
       break;
@@ -926,16 +928,17 @@ AudioManager::GetMaxAudioChannelVolume(u
   switch (static_cast<AudioChannel>(aChannel)) {
     case AudioChannel::Normal:
     case AudioChannel::Content:
       *aMaxIndex = GetMaxVolumeByCategory(VOLUME_MEDIA);
       break;
     case AudioChannel::Notification:
     case AudioChannel::Ringer:
     case AudioChannel::Publicnotification:
+    case AudioChannel::System:
       *aMaxIndex = GetMaxVolumeByCategory(VOLUME_NOTIFICATION);
       break;
     case AudioChannel::Alarm:
       *aMaxIndex = GetMaxVolumeByCategory(VOLUME_ALARM);
       break;
     case AudioChannel::Telephony:
       *aMaxIndex = GetMaxVolumeByCategory(category);
       break;
--- a/dom/webidl/AudioChannel.webidl
+++ b/dom/webidl/AudioChannel.webidl
@@ -41,9 +41,10 @@
 enum AudioChannel {
   "normal",
   "content",
   "notification",
   "alarm",
   "telephony",
   "ringer",
   "publicnotification",
+  "system"
 };