Bug 987064 - Remove AudioChannelType, r=roc, r=mchen, r=bent

This commit is contained in:
Andrea Marchesini 2014-04-10 11:49:23 +01:00
parent 993f02b514
commit 190cf6a2a2
27 changed files with 364 additions and 399 deletions

View File

@ -12,7 +12,7 @@
#define nsAttrValue_h___
#include "nscore.h"
#include "nsString.h"
#include "nsStringGlue.h"
#include "nsStringBuffer.h"
#include "nsColor.h"
#include "nsCaseTreatment.h"

View File

@ -496,7 +496,11 @@ public:
double MozFragmentEnd();
AudioChannel MozAudioChannelType() const;
AudioChannel MozAudioChannelType() const
{
return mAudioChannel;
}
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
TextTrackList* TextTracks();
@ -1122,8 +1126,8 @@ protected:
// True if the media's channel's download has been suspended.
bool mDownloadSuspendedByCache;
// Audio Channel Type.
AudioChannelType mAudioChannelType;
// Audio Channel.
AudioChannel mAudioChannel;
// The audio channel has been faded.
bool mAudioChannelFaded;

View File

@ -2004,7 +2004,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
mCORSMode(CORS_NONE),
mHasAudio(false),
mDownloadSuspendedByCache(false),
mAudioChannelType(AUDIO_CHANNEL_NORMAL),
mAudioChannelFaded(false),
mPlayingThroughTheAudioChannel(false)
{
@ -2017,6 +2016,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
}
#endif
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
mPaused.SetOuter(this);
RegisterFreezableElement();
@ -2282,18 +2283,6 @@ bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
{ 0 }
};
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
static const nsAttrValue::EnumTable kMozAudioChannelAttributeTable[] = {
{ "normal", AUDIO_CHANNEL_NORMAL },
{ "content", AUDIO_CHANNEL_CONTENT },
{ "notification", AUDIO_CHANNEL_NOTIFICATION },
{ "alarm", AUDIO_CHANNEL_ALARM },
{ "telephony", AUDIO_CHANNEL_TELEPHONY },
{ "ringer", AUDIO_CHANNEL_RINGER },
{ "publicnotification", AUDIO_CHANNEL_PUBLICNOTIFICATION },
{ 0 }
};
if (aNamespaceID == kNameSpaceID_None) {
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return true;
@ -2307,18 +2296,21 @@ bool HTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
}
if (aAttribute == nsGkAtoms::mozaudiochannel) {
bool parsed = aResult.ParseEnumValue(aValue, kMozAudioChannelAttributeTable, false,
&kMozAudioChannelAttributeTable[0]);
const nsAttrValue::EnumTable* table =
AudioChannelService::GetAudioChannelTable();
MOZ_ASSERT(table);
bool parsed = aResult.ParseEnumValue(aValue, table, false, &table[0]);
if (!parsed) {
return false;
}
AudioChannelType audioChannelType = static_cast<AudioChannelType>(aResult.GetEnumValue());
AudioChannel audioChannel = static_cast<AudioChannel>(aResult.GetEnumValue());
if (audioChannelType != mAudioChannelType &&
if (audioChannel != mAudioChannel &&
!mDecoder &&
CheckAudioChannelPermissions(aValue)) {
mAudioChannelType = audioChannelType;
mAudioChannel = audioChannel;
}
return true;
@ -2604,7 +2596,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
// Tell the decoder about its MediaResource now so things like principals are
// available immediately.
mDecoder->SetResource(aStream);
mDecoder->SetAudioChannelType(mAudioChannelType);
aDecoder->SetAudioChannel(mAudioChannel);
mDecoder->SetAudioCaptured(mAudioCaptured);
mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
mDecoder->SetPreservesPitch(mPreservesPitch);
@ -3846,12 +3838,14 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
}
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
// Use a weak ref so the audio channel agent can't leak |this|.
if (AUDIO_CHANNEL_NORMAL == mAudioChannelType && video) {
if (AudioChannel::Normal == mAudioChannel && video) {
mAudioChannelAgent->InitWithVideo(OwnerDoc()->GetWindow(),
mAudioChannelType, this, true);
static_cast<int32_t>(mAudioChannel),
this, true);
} else {
mAudioChannelAgent->InitWithWeakCallback(OwnerDoc()->GetWindow(),
mAudioChannelType, this);
static_cast<int32_t>(mAudioChannel),
this);
}
mAudioChannelAgent->SetVisibilityState(!OwnerDoc()->Hidden());
}
@ -3931,33 +3925,6 @@ HTMLMediaElement::GetOrCreateTextTrackManager()
return mTextTrackManager;
}
AudioChannel
HTMLMediaElement::MozAudioChannelType() const
{
switch (mAudioChannelType) {
case AUDIO_CHANNEL_CONTENT:
return AudioChannel::Content;
case AUDIO_CHANNEL_NOTIFICATION:
return AudioChannel::Notification;
case AUDIO_CHANNEL_ALARM:
return AudioChannel::Alarm;
case AUDIO_CHANNEL_TELEPHONY:
return AudioChannel::Telephony;
case AUDIO_CHANNEL_RINGER:
return AudioChannel::Ringer;
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
return AudioChannel::Publicnotification;
default:
return AudioChannelService::GetDefaultAudioChannel();
}
}
void
HTMLMediaElement::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
{

View File

@ -110,25 +110,25 @@ bool AudioStream::sCubebLatencyPrefSet;
}
#if defined(__ANDROID__) && defined(MOZ_B2G)
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannelType aType)
static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
{
switch(aType) {
case dom::AUDIO_CHANNEL_NORMAL:
switch(aChannel) {
case dom::AudioChannel::Normal:
return CUBEB_STREAM_TYPE_SYSTEM;
case dom::AUDIO_CHANNEL_CONTENT:
case dom::AudioChannel::Content:
return CUBEB_STREAM_TYPE_MUSIC;
case dom::AUDIO_CHANNEL_NOTIFICATION:
case dom::AudioChannel::Notification:
return CUBEB_STREAM_TYPE_NOTIFICATION;
case dom::AUDIO_CHANNEL_ALARM:
case dom::AudioChannel::Alarm:
return CUBEB_STREAM_TYPE_ALARM;
case dom::AUDIO_CHANNEL_TELEPHONY:
case dom::AudioChannel::Telephony:
return CUBEB_STREAM_TYPE_VOICE_CALL;
case dom::AUDIO_CHANNEL_RINGER:
case dom::AudioChannel::Ringer:
return CUBEB_STREAM_TYPE_RING;
// Currently Android openSLES library doesn't support FORCE_AUDIBLE yet.
case dom::AUDIO_CHANNEL_PUBLICNOTIFICATION:
case dom::AudioChannel::Publicnotification:
default:
NS_ERROR("The value of AudioChannelType is invalid");
NS_ERROR("The value of AudioChannel is invalid");
return CUBEB_STREAM_TYPE_MAX;
}
}
@ -349,7 +349,7 @@ WriteDumpFile(FILE* aDumpFile, AudioStream* aStream, uint32_t aFrames,
nsresult
AudioStream::Init(int32_t aNumChannels, int32_t aRate,
const dom::AudioChannelType aAudioChannelType,
const dom::AudioChannel aAudioChannel,
LatencyRequest aLatencyRequest)
{
cubeb* cubebContext = GetCubebContext();
@ -372,7 +372,7 @@ AudioStream::Init(int32_t aNumChannels, int32_t aRate,
params.channels = mOutChannels;
#if defined(__ANDROID__)
#if defined(MOZ_B2G)
params.stream_type = ConvertChannelToCubebType(aAudioChannelType);
params.stream_type = ConvertChannelToCubebType(aAudioChannel);
#else
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif

View File

@ -7,11 +7,11 @@
#define AudioStream_h_
#include "AudioSampleFormat.h"
#include "AudioChannelCommon.h"
#include "nsAutoPtr.h"
#include "nsAutoRef.h"
#include "nsCOMPtr.h"
#include "Latency.h"
#include "mozilla/dom/AudioChannelBinding.h"
#include "mozilla/StaticMutex.h"
#include "cubeb/cubeb.h"
@ -198,7 +198,7 @@ public:
// channels (1 for mono, 2 for stereo, etc) and aRate is the sample rate
// (22050Hz, 44100Hz, etc).
nsresult Init(int32_t aNumChannels, int32_t aRate,
const dom::AudioChannelType aAudioStreamType,
const dom::AudioChannel aAudioStreamChannel,
LatencyRequest aLatencyRequest);
// Closes the stream. All future use of the stream is an error.

View File

@ -23,6 +23,7 @@
#include "nsITimer.h"
#include <algorithm>
#include "MediaShutdownManager.h"
#include "AudioChannelService.h"
#ifdef MOZ_WMF
#include "WMFDecoder.h"
@ -427,7 +428,6 @@ MediaDecoder::MediaDecoder() :
mPinnedForSeek(false),
mShuttingDown(false),
mPausedForPlaybackRateNull(false),
mAudioChannelType(AUDIO_CHANNEL_NORMAL),
mMinimizePreroll(false)
{
MOZ_COUNT_CTOR(MediaDecoder);
@ -438,6 +438,8 @@ MediaDecoder::MediaDecoder() :
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
}
#endif
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
}
bool MediaDecoder::Init(MediaDecoderOwner* aOwner)

View File

@ -183,11 +183,11 @@ destroying the MediaDecoder object.
#include "nsIObserver.h"
#include "nsAutoPtr.h"
#include "MediaResource.h"
#include "mozilla/dom/AudioChannelBinding.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/TimeStamp.h"
#include "MediaStreamGraph.h"
#include "AudioChannelCommon.h"
#include "AbstractMediaDecoder.h"
#include "necko-config.h"
@ -739,8 +739,8 @@ public:
// held.
void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
void SetAudioChannelType(dom::AudioChannelType aType) { mAudioChannelType = aType; }
dom::AudioChannelType GetAudioChannelType() { return mAudioChannelType; }
void SetAudioChannel(dom::AudioChannel aChannel) { mAudioChannel = aChannel; }
dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
// Send a new set of metadata to the state machine, to be dispatched to the
// main thread to be presented when the |currentTime| of the media is greater
@ -1205,7 +1205,7 @@ protected:
// Be assigned from media element during the initialization and pass to
// AudioStream Class.
dom::AudioChannelType mAudioChannelType;
dom::AudioChannel mAudioChannel;
// True if the decoder has been directed to minimize its preroll before
// playback starts. After the first time playback starts, we don't attempt

View File

@ -763,7 +763,7 @@ void MediaDecoderStateMachine::AudioLoop()
bool setPlaybackRate;
bool preservesPitch;
bool setPreservesPitch;
AudioChannelType audioChannelType;
AudioChannel audioChannel;
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
@ -773,7 +773,7 @@ void MediaDecoderStateMachine::AudioLoop()
channels = mInfo.mAudio.mChannels;
rate = mInfo.mAudio.mRate;
audioChannelType = mDecoder->GetAudioChannelType();
audioChannel = mDecoder->GetAudioChannel();
volume = mVolume;
preservesPitch = mPreservesPitch;
playbackRate = mPlaybackRate;
@ -784,7 +784,7 @@ void MediaDecoderStateMachine::AudioLoop()
// circumstances, so we take care to drop the decoder monitor while
// initializing.
nsAutoPtr<AudioStream> audioStream(new AudioStream());
audioStream->Init(channels, rate, audioChannelType, AudioStream::HighLatency);
audioStream->Init(channels, rate, audioChannel, AudioStream::HighLatency);
audioStream->SetVolume(volume);
if (audioStream->SetPreservesPitch(preservesPitch) != NS_OK) {
NS_WARNING("Setting the pitch preservation failed at AudioLoop start.");

View File

@ -18,7 +18,7 @@
#include "mozilla/Attributes.h"
#include "TrackUnionStream.h"
#include "ImageContainer.h"
#include "AudioChannelCommon.h"
#include "AudioChannelService.h"
#include "AudioNodeEngine.h"
#include "AudioNodeStream.h"
#include "AudioNodeExternalInputStream.h"
@ -811,7 +811,9 @@ MediaStreamGraphImpl::CreateOrDestroyAudioStreams(GraphTime aAudioOutputStartTim
audioOutputStream->mStream = new AudioStream();
// XXX for now, allocate stereo output. But we need to fix this to
// match the system's ideal channel configuration.
audioOutputStream->mStream->Init(2, tracks->GetRate(), AUDIO_CHANNEL_NORMAL, AudioStream::LowLatency);
audioOutputStream->mStream->Init(2, tracks->GetRate(),
AudioChannel::Normal,
AudioStream::LowLatency);
audioOutputStream->mTrackID = tracks->GetID();
LogLatency(AsyncLatencyLogger::AudioStreamCreate,

View File

@ -477,40 +477,10 @@ AudioDestinationNode::CreateAudioChannelAgent()
mAudioChannelAgent->StopPlaying();
}
AudioChannelType type = AUDIO_CHANNEL_NORMAL;
switch(mAudioChannel) {
case AudioChannel::Normal:
type = AUDIO_CHANNEL_NORMAL;
break;
case AudioChannel::Content:
type = AUDIO_CHANNEL_CONTENT;
break;
case AudioChannel::Notification:
type = AUDIO_CHANNEL_NOTIFICATION;
break;
case AudioChannel::Alarm:
type = AUDIO_CHANNEL_ALARM;
break;
case AudioChannel::Telephony:
type = AUDIO_CHANNEL_TELEPHONY;
break;
case AudioChannel::Ringer:
type = AUDIO_CHANNEL_RINGER;
break;
case AudioChannel::Publicnotification:
type = AUDIO_CHANNEL_PUBLICNOTIFICATION;
break;
}
mAudioChannelAgent = new AudioChannelAgent();
mAudioChannelAgent->InitWithWeakCallback(GetOwner(), type, this);
mAudioChannelAgent->InitWithWeakCallback(GetOwner(),
static_cast<int32_t>(mAudioChannel),
this);
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(GetOwner());
if (docshell) {

View File

@ -12,7 +12,7 @@
* types don't need to be exported outside the SVG module.
*/
#include "nsString.h"
#include "nsStringGlue.h"
class nsSVGAngle;
class nsSVGIntegerPair;

View File

@ -84,22 +84,22 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
MOZ_ASSERT(aWindow || XRE_GetProcessType() == GeckoProcessType_Default);
// We syncd the enum of channel type between nsIAudioChannelAgent.idl and
// AudioChannelCommon.h the same.
static_assert(static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NORMAL) ==
AUDIO_CHANNEL_NORMAL &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_CONTENT) ==
AUDIO_CHANNEL_CONTENT &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
AUDIO_CHANNEL_NOTIFICATION &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_ALARM) ==
AUDIO_CHANNEL_ALARM &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
AUDIO_CHANNEL_TELEPHONY &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_RINGER) ==
AUDIO_CHANNEL_RINGER &&
static_cast<AudioChannelType>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
AUDIO_CHANNEL_PUBLICNOTIFICATION,
"Enum of channel on nsIAudioChannelAgent.idl should be the same with AudioChannelCommon.h");
// AudioChannelBinding.h the same.
MOZ_ASSERT(static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NORMAL) ==
AudioChannel::Normal &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_CONTENT) ==
AudioChannel::Content &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_NOTIFICATION) ==
AudioChannel::Notification &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_ALARM) ==
AudioChannel::Alarm &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_TELEPHONY) ==
AudioChannel::Telephony &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_RINGER) ==
AudioChannel::Ringer &&
static_cast<AudioChannel>(AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION) ==
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 ||
@ -131,7 +131,7 @@ NS_IMETHODIMP AudioChannelAgent::StartPlaying(int32_t *_retval)
}
service->RegisterAudioChannelAgent(this,
static_cast<AudioChannelType>(mAudioChannelType), mWithVideo);
static_cast<AudioChannel>(mAudioChannelType), mWithVideo);
*_retval = service->GetState(this, !mVisible);
mIsRegToService = true;
return NS_OK;

View File

@ -10,20 +10,6 @@
namespace mozilla {
namespace dom {
// The audio channel. Read the nsIHTMLMediaElement.idl for a description
// about this attribute.
enum AudioChannelType {
AUDIO_CHANNEL_DEFAULT = -1,
AUDIO_CHANNEL_NORMAL = 0,
AUDIO_CHANNEL_CONTENT,
AUDIO_CHANNEL_NOTIFICATION,
AUDIO_CHANNEL_ALARM,
AUDIO_CHANNEL_TELEPHONY,
AUDIO_CHANNEL_RINGER,
AUDIO_CHANNEL_PUBLICNOTIFICATION,
AUDIO_CHANNEL_LAST
};
enum AudioChannelState {
AUDIO_CHANNEL_STATE_NORMAL = 0,
AUDIO_CHANNEL_STATE_MUTED,

View File

@ -37,6 +37,18 @@ using namespace mozilla::hal;
StaticRefPtr<AudioChannelService> gAudioChannelService;
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
static const nsAttrValue::EnumTable kMozAudioChannelAttributeTable[] = {
{ "normal", (int16_t)AudioChannel::Normal },
{ "content", (int16_t)AudioChannel::Content },
{ "notification", (int16_t)AudioChannel::Notification },
{ "alarm", (int16_t)AudioChannel::Alarm },
{ "telephony", (int16_t)AudioChannel::Telephony },
{ "ringer", (int16_t)AudioChannel::Ringer },
{ "publicnotification", (int16_t)AudioChannel::Publicnotification },
{ nullptr }
};
// static
AudioChannelService*
AudioChannelService::GetAudioChannelService()
@ -75,8 +87,8 @@ AudioChannelService::Shutdown()
NS_IMPL_ISUPPORTS2(AudioChannelService, nsIObserver, nsITimerCallback)
AudioChannelService::AudioChannelService()
: mCurrentHigherChannel(AUDIO_CHANNEL_LAST)
, mCurrentVisibleHigherChannel(AUDIO_CHANNEL_LAST)
: mCurrentHigherChannel(INT32_MAX)
, mCurrentVisibleHigherChannel(INT32_MAX)
, mPlayableHiddenContentChildID(CONTENT_PROCESS_ID_UNKNOWN)
, mDisabled(false)
, mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN)
@ -100,21 +112,19 @@ AudioChannelService::~AudioChannelService()
void
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannelType aType,
AudioChannel aChannel,
bool aWithVideo)
{
if (mDisabled) {
return;
}
MOZ_ASSERT(aType != AUDIO_CHANNEL_DEFAULT);
AudioChannelAgentData* data = new AudioChannelAgentData(aType,
AudioChannelAgentData* data = new AudioChannelAgentData(aChannel,
true /* aElementHidden */,
AUDIO_CHANNEL_STATE_MUTED /* aState */,
aWithVideo);
mAgents.Put(aAgent, data);
RegisterType(aType, CONTENT_PROCESS_ID_MAIN, aWithVideo);
RegisterType(aChannel, CONTENT_PROCESS_ID_MAIN, aWithVideo);
// If this is the first agent for this window, we must notify the observers.
uint32_t count = CountWindow(aAgent->Window());
@ -130,22 +140,24 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
}
void
AudioChannelService::RegisterType(AudioChannelType aType, uint64_t aChildID, bool aWithVideo)
AudioChannelService::RegisterType(AudioChannel aChannel, uint64_t aChildID,
bool aWithVideo)
{
if (mDisabled) {
return;
}
AudioChannelInternalType type = GetInternalType(aType, true);
AudioChannelInternalType type = GetInternalType(aChannel, true);
mChannelCounters[type].AppendElement(aChildID);
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// Since there is another telephony registered, we can unregister old one
// immediately.
if (mDeferTelChannelTimer && aType == AUDIO_CHANNEL_TELEPHONY) {
if (mDeferTelChannelTimer && aChannel == AudioChannel::Telephony) {
mDeferTelChannelTimer->Cancel();
mDeferTelChannelTimer = nullptr;
UnregisterTypeInternal(aType, mTimerElementHidden, mTimerChildID, false);
UnregisterTypeInternal(aChannel, mTimerElementHidden, mTimerChildID,
false);
}
if (aWithVideo) {
@ -186,7 +198,7 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
mAgents.RemoveAndForget(aAgent, data);
if (data) {
UnregisterType(data->mType, data->mElementHidden,
UnregisterType(data->mChannel, data->mElementHidden,
CONTENT_PROCESS_ID_MAIN, data->mWithVideo);
}
#ifdef MOZ_WIDGET_GONK
@ -210,7 +222,7 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
}
void
AudioChannelService::UnregisterType(AudioChannelType aType,
AudioChannelService::UnregisterType(AudioChannel aChannel,
bool aElementHidden,
uint64_t aChildID,
bool aWithVideo)
@ -223,7 +235,7 @@ AudioChannelService::UnregisterType(AudioChannelType aType,
// 1. User can have time to remove device from his ear before music resuming.
// 2. Give BT SCO to be disconnected before starting to connect A2DP.
if (XRE_GetProcessType() == GeckoProcessType_Default &&
aType == AUDIO_CHANNEL_TELEPHONY &&
aChannel == AudioChannel::Telephony &&
(mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].Length() +
mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].Length()) == 1) {
mTimerElementHidden = aElementHidden;
@ -233,18 +245,18 @@ AudioChannelService::UnregisterType(AudioChannelType aType,
return;
}
UnregisterTypeInternal(aType, aElementHidden, aChildID, aWithVideo);
UnregisterTypeInternal(aChannel, aElementHidden, aChildID, aWithVideo);
}
void
AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
AudioChannelService::UnregisterTypeInternal(AudioChannel aChannel,
bool aElementHidden,
uint64_t aChildID,
bool aWithVideo)
{
// The array may contain multiple occurrence of this appId but
// this should remove only the first one.
AudioChannelInternalType type = GetInternalType(aType, aElementHidden);
AudioChannelInternalType type = GetInternalType(aChannel, aElementHidden);
MOZ_ASSERT(mChannelCounters[type].Contains(aChildID));
mChannelCounters[type].RemoveElement(aChildID);
@ -253,7 +265,7 @@ AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// No hidden content channel is playable if the original playable hidden
// process does not need to play audio from background anymore.
if (aType == AUDIO_CHANNEL_CONTENT &&
if (aChannel == AudioChannel::Content &&
mPlayableHiddenContentChildID == aChildID &&
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].Contains(aChildID)) {
mPlayableHiddenContentChildID = CONTENT_PROCESS_ID_UNKNOWN;
@ -270,14 +282,14 @@ AudioChannelService::UnregisterTypeInternal(AudioChannelType aType,
}
void
AudioChannelService::UpdateChannelType(AudioChannelType aType,
AudioChannelService::UpdateChannelType(AudioChannel aChannel,
uint64_t aChildID,
bool aElementHidden,
bool aElementWasHidden)
{
// Calculate the new and old internal type and update the hashtable if needed.
AudioChannelInternalType newType = GetInternalType(aType, aElementHidden);
AudioChannelInternalType oldType = GetInternalType(aType, aElementWasHidden);
AudioChannelInternalType newType = GetInternalType(aChannel, aElementHidden);
AudioChannelInternalType oldType = GetInternalType(aChannel, aElementWasHidden);
if (newType != oldType) {
mChannelCounters[newType].AppendElement(aChildID);
@ -315,24 +327,26 @@ AudioChannelService::GetState(AudioChannelAgent* aAgent, bool aElementHidden)
// Update visibility.
data->mElementHidden = aElementHidden;
data->mState = GetStateInternal(data->mType, CONTENT_PROCESS_ID_MAIN,
data->mState = GetStateInternal(data->mChannel, CONTENT_PROCESS_ID_MAIN,
aElementHidden, oldElementHidden);
return data->mState;
}
AudioChannelState
AudioChannelService::GetStateInternal(AudioChannelType aType, uint64_t aChildID,
bool aElementHidden, bool aElementWasHidden)
AudioChannelService::GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
bool aElementHidden,
bool aElementWasHidden)
{
UpdateChannelType(aType, aChildID, aElementHidden, aElementWasHidden);
UpdateChannelType(aChannel, aChildID, aElementHidden, aElementWasHidden);
// Calculating the new and old type and update the hashtable if needed.
AudioChannelInternalType newType = GetInternalType(aType, aElementHidden);
AudioChannelInternalType oldType = GetInternalType(aType, aElementWasHidden);
AudioChannelInternalType newType = GetInternalType(aChannel, aElementHidden);
AudioChannelInternalType oldType = GetInternalType(aChannel,
aElementWasHidden);
if (newType != oldType &&
(aType == AUDIO_CHANNEL_CONTENT ||
(aType == AUDIO_CHANNEL_NORMAL &&
(aChannel == AudioChannel::Content ||
(aChannel == AudioChannel::Normal &&
mWithVideoChildIDs.Contains(aChildID)))) {
Notify();
}
@ -427,15 +441,17 @@ AudioChannelService::ProcessContentOrNormalChannelIsActive(uint64_t aChildID)
}
void
AudioChannelService::SetDefaultVolumeControlChannel(AudioChannelType aType,
AudioChannelService::SetDefaultVolumeControlChannel(int32_t aChannel,
bool aHidden)
{
SetDefaultVolumeControlChannelInternal(aType, aHidden, CONTENT_PROCESS_ID_MAIN);
SetDefaultVolumeControlChannelInternal(aChannel, aHidden,
CONTENT_PROCESS_ID_MAIN);
}
void
AudioChannelService::SetDefaultVolumeControlChannelInternal(
AudioChannelType aType, bool aHidden, uint64_t aChildID)
AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel,
bool aHidden,
uint64_t aChildID)
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return;
@ -450,7 +466,13 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(
mDefChannelChildID = aChildID;
nsString channelName;
channelName.AssignASCII(ChannelName(aType));
if (aChannel == -1) {
channelName.AssignASCII("unknown");
} else {
GetAudioChannelString(static_cast<AudioChannel>(aChannel), channelName);
}
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "default-volume-channel-changed",
@ -475,52 +497,57 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
}
// Calculating the most important active channel.
AudioChannelType higher = AUDIO_CHANNEL_DEFAULT;
int32_t higher = -1;
// Top-Down in the hierarchy for visible elements
if (!mChannelCounters[AUDIO_CHANNEL_INT_PUBLICNOTIFICATION].IsEmpty()) {
higher = AUDIO_CHANNEL_PUBLICNOTIFICATION;
higher = static_cast<int32_t>(AudioChannel::Publicnotification);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_RINGER].IsEmpty()) {
higher = AUDIO_CHANNEL_RINGER;
higher = static_cast<int32_t>(AudioChannel::Ringer);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].IsEmpty()) {
higher = AUDIO_CHANNEL_TELEPHONY;
higher = static_cast<int32_t>(AudioChannel::Telephony);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_ALARM].IsEmpty()) {
higher = AUDIO_CHANNEL_ALARM;
higher = static_cast<int32_t>(AudioChannel::Alarm);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NOTIFICATION].IsEmpty()) {
higher = AUDIO_CHANNEL_NOTIFICATION;
higher = static_cast<int32_t>(AudioChannel::Notification);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT].IsEmpty()) {
higher = AUDIO_CHANNEL_CONTENT;
higher = static_cast<int32_t>(AudioChannel::Content);
}
else if (!mChannelCounters[AUDIO_CHANNEL_INT_NORMAL].IsEmpty()) {
higher = AUDIO_CHANNEL_NORMAL;
higher = static_cast<int32_t>(AudioChannel::Normal);
}
AudioChannelType visibleHigher = higher;
int32_t visibleHigher = higher;
// Top-Down in the hierarchy for non-visible elements
// And we can ignore normal channel because it can't play in the background.
for (int i = AUDIO_CHANNEL_LAST - 1;
i > higher && i > AUDIO_CHANNEL_NORMAL; i--) {
if (i == AUDIO_CHANNEL_CONTENT &&
int32_t index;
for (index = 0; kMozAudioChannelAttributeTable[index].tag; ++index);
for (--index;
kMozAudioChannelAttributeTable[index].value > higher &&
kMozAudioChannelAttributeTable[index].value > (int16_t)AudioChannel::Normal;
--index) {
if (kMozAudioChannelAttributeTable[index].value == (int16_t)AudioChannel::Content &&
mPlayableHiddenContentChildID != CONTENT_PROCESS_ID_UNKNOWN) {
higher = static_cast<AudioChannelType>(i);
higher = kMozAudioChannelAttributeTable[index].value;
}
// Each channel type will be split to fg and bg for recording the state,
// so here need to do a translation.
if (!mChannelCounters[i * 2 + 1].IsEmpty()) {
higher = static_cast<AudioChannelType>(i);
if (!mChannelCounters[index * 2 + 1].IsEmpty()) {
higher = kMozAudioChannelAttributeTable[index].value;
break;
}
}
@ -529,8 +556,9 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
mCurrentHigherChannel = higher;
nsString channelName;
if (mCurrentHigherChannel != AUDIO_CHANNEL_DEFAULT) {
channelName.AssignASCII(ChannelName(mCurrentHigherChannel));
if (mCurrentHigherChannel != -1) {
GetAudioChannelString(static_cast<AudioChannel>(mCurrentHigherChannel),
channelName);
} else {
channelName.AssignLiteral("none");
}
@ -544,8 +572,9 @@ AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
mCurrentVisibleHigherChannel = visibleHigher;
nsString channelName;
if (mCurrentVisibleHigherChannel != AUDIO_CHANNEL_DEFAULT) {
channelName.AssignASCII(ChannelName(mCurrentVisibleHigherChannel));
if (mCurrentVisibleHigherChannel != -1) {
GetAudioChannelString(static_cast<AudioChannel>(mCurrentVisibleHigherChannel),
channelName);
} else {
channelName.AssignLiteral("none");
}
@ -584,7 +613,8 @@ AudioChannelService::Notify()
NS_IMETHODIMP
AudioChannelService::Notify(nsITimer* aTimer)
{
UnregisterTypeInternal(AUDIO_CHANNEL_TELEPHONY, mTimerElementHidden, mTimerChildID, false);
UnregisterTypeInternal(AudioChannel::Telephony, mTimerElementHidden,
mTimerChildID, false);
mDeferTelChannelTimer = nullptr;
return NS_OK;
}
@ -620,34 +650,6 @@ AudioChannelService::ChannelsActiveWithHigherPriorityThan(
return false;
}
const char*
AudioChannelService::ChannelName(AudioChannelType aType)
{
static struct {
int32_t type;
const char* value;
} ChannelNameTable[] = {
{ AUDIO_CHANNEL_NORMAL, "normal" },
{ AUDIO_CHANNEL_CONTENT, "content" },
{ AUDIO_CHANNEL_NOTIFICATION, "notification" },
{ AUDIO_CHANNEL_ALARM, "alarm" },
{ AUDIO_CHANNEL_TELEPHONY, "telephony" },
{ AUDIO_CHANNEL_RINGER, "ringer" },
{ AUDIO_CHANNEL_PUBLICNOTIFICATION, "publicnotification" },
{ -1, "unknown" }
};
for (int i = AUDIO_CHANNEL_NORMAL; ; ++i) {
if (ChannelNameTable[i].type == aType ||
ChannelNameTable[i].type == -1) {
return ChannelNameTable[i].value;
}
}
NS_NOTREACHED("Execution should not reach here!");
return nullptr;
}
NS_IMETHODIMP
AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
{
@ -693,8 +695,7 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
Notify();
if (mDefChannelChildID == childID) {
SetDefaultVolumeControlChannelInternal(AUDIO_CHANNEL_DEFAULT,
false, childID);
SetDefaultVolumeControlChannelInternal(-1, false, childID);
mDefChannelChildID = CONTENT_PROCESS_ID_UNKNOWN;
}
} else {
@ -739,13 +740,13 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
int32_t index = value.toInt32();
if (keyStr.EqualsLiteral("audio.volume.content")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_CONTENT, index);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content, index);
} else if (keyStr.EqualsLiteral("audio.volume.notification")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_NOTIFICATION, index);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Notification, index);
} else if (keyStr.EqualsLiteral("audio.volume.alarm")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_ALARM, index);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Alarm, index);
} else if (keyStr.EqualsLiteral("audio.volume.telephony")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_TELEPHONY, index);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Telephony, index);
} else if (!keyStr.EqualsLiteral("audio.volume.bt_sco")) {
// bt_sco is not a valid audio channel so we manipulate it in
// AudioManager.cpp. And the others should not be used.
@ -761,51 +762,50 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
}
AudioChannelService::AudioChannelInternalType
AudioChannelService::GetInternalType(AudioChannelType aType,
AudioChannelService::GetInternalType(AudioChannel aChannel,
bool aElementHidden)
{
switch (aType) {
case AUDIO_CHANNEL_NORMAL:
switch (aChannel) {
case AudioChannel::Normal:
return aElementHidden
? AUDIO_CHANNEL_INT_NORMAL_HIDDEN
: AUDIO_CHANNEL_INT_NORMAL;
case AUDIO_CHANNEL_CONTENT:
case AudioChannel::Content:
return aElementHidden
? AUDIO_CHANNEL_INT_CONTENT_HIDDEN
: AUDIO_CHANNEL_INT_CONTENT;
case AUDIO_CHANNEL_NOTIFICATION:
case AudioChannel::Notification:
return aElementHidden
? AUDIO_CHANNEL_INT_NOTIFICATION_HIDDEN
: AUDIO_CHANNEL_INT_NOTIFICATION;
case AUDIO_CHANNEL_ALARM:
case AudioChannel::Alarm:
return aElementHidden
? AUDIO_CHANNEL_INT_ALARM_HIDDEN
: AUDIO_CHANNEL_INT_ALARM;
case AUDIO_CHANNEL_TELEPHONY:
case AudioChannel::Telephony:
return aElementHidden
? AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN
: AUDIO_CHANNEL_INT_TELEPHONY;
case AUDIO_CHANNEL_RINGER:
case AudioChannel::Ringer:
return aElementHidden
? AUDIO_CHANNEL_INT_RINGER_HIDDEN
: AUDIO_CHANNEL_INT_RINGER;
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
case AudioChannel::Publicnotification:
return aElementHidden
? AUDIO_CHANNEL_INT_PUBLICNOTIFICATION_HIDDEN
: AUDIO_CHANNEL_INT_PUBLICNOTIFICATION;
case AUDIO_CHANNEL_LAST:
default:
break;
}
MOZ_CRASH("unexpected audio channel type");
MOZ_CRASH("unexpected audio channel");
}
struct RefreshAgentsVolumeData
@ -883,21 +883,23 @@ AudioChannelService::CountWindow(nsIDOMWindow* aWindow)
return data.mCount;
}
// Mappings from 'mozaudiochannel' attribute strings to an enumeration.
static const struct AudioChannelTable
/* static */ const nsAttrValue::EnumTable*
AudioChannelService::GetAudioChannelTable()
{
const char* string;
AudioChannel value;
} kMozAudioChannelAttributeTable[] = {
{ "normal", AudioChannel::Normal },
{ "content", AudioChannel::Content },
{ "notification", AudioChannel::Notification },
{ "alarm", AudioChannel::Alarm },
{ "telephony", AudioChannel::Telephony },
{ "ringer", AudioChannel::Ringer },
{ "publicnotification", AudioChannel::Publicnotification },
{ nullptr }
};
return kMozAudioChannelAttributeTable;
}
/* static */ AudioChannel
AudioChannelService::GetAudioChannel(const nsAString& aChannel)
{
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
if (aChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
}
}
return AudioChannel::Normal;
}
/* static */ AudioChannel
AudioChannelService::GetDefaultAudioChannel()
@ -907,9 +909,9 @@ AudioChannelService::GetDefaultAudioChannel()
return AudioChannel::Normal;
}
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].string; ++i) {
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].string)) {
return kMozAudioChannelAttributeTable[i].value;
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
}
}
@ -917,14 +919,29 @@ AudioChannelService::GetDefaultAudioChannel()
}
/* static */ void
AudioChannelService::GetDefaultAudioChannelString(nsString& aString)
AudioChannelService::GetAudioChannelString(AudioChannel aChannel,
nsAString& aString)
{
aString.AssignASCII("normal");
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
if (aChannel ==
static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value)) {
aString.AssignASCII(kMozAudioChannelAttributeTable[i].tag);
break;
}
}
}
/* static */ void
AudioChannelService::GetDefaultAudioChannelString(nsAString& aString)
{
aString.AssignASCII("normal");
nsString audioChannel = Preferences::GetString("media.defaultAudioChannel");
if (!audioChannel.IsEmpty()) {
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].string; ++i) {
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].string)) {
for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
aString = audioChannel;
break;
}

View File

@ -14,6 +14,7 @@
#include "AudioChannelCommon.h"
#include "AudioChannelAgent.h"
#include "nsAttrValue.h"
#include "nsClassHashtable.h"
#include "mozilla/dom/AudioChannelBinding.h"
@ -48,10 +49,10 @@ public:
/**
* Any audio channel agent that starts playing should register itself to
* this service, sharing the AudioChannelType.
* this service, sharing the AudioChannel.
*/
virtual void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannelType aType,
AudioChannel aChannel,
bool aWithVideo);
/**
@ -81,9 +82,11 @@ public:
/***
* AudioChannelManager calls this function to notify the default channel used
* to adjust volume when there is no any active channel.
* to adjust volume when there is no any active channel. if aChannel is -1,
* the default audio channel will be used. Otherwise aChannel is casted to
* AudioChannel enum.
*/
virtual void SetDefaultVolumeControlChannel(AudioChannelType aType,
virtual void SetDefaultVolumeControlChannel(int32_t aChannel,
bool aHidden);
bool AnyAudioChannelIsActive();
@ -104,8 +107,11 @@ public:
}
#endif
static const nsAttrValue::EnumTable* GetAudioChannelTable();
static AudioChannel GetAudioChannel(const nsAString& aString);
static AudioChannel GetDefaultAudioChannel();
static void GetDefaultAudioChannelString(nsString& aString);
static void GetAudioChannelString(AudioChannel aChannel, nsAString& aString);
static void GetDefaultAudioChannelString(nsAString& aString);
protected:
void Notify();
@ -117,22 +123,22 @@ protected:
void SendAudioChannelChangedNotification(uint64_t aChildID);
/* Register/Unregister IPC types: */
void RegisterType(AudioChannelType aType, uint64_t aChildID, bool aWithVideo);
void UnregisterType(AudioChannelType aType, bool aElementHidden,
void RegisterType(AudioChannel aChannel, uint64_t aChildID, bool aWithVideo);
void UnregisterType(AudioChannel aChannel, bool aElementHidden,
uint64_t aChildID, bool aWithVideo);
void UnregisterTypeInternal(AudioChannelType aType, bool aElementHidden,
void UnregisterTypeInternal(AudioChannel aChannel, bool aElementHidden,
uint64_t aChildID, bool aWithVideo);
AudioChannelState GetStateInternal(AudioChannelType aType, uint64_t aChildID,
AudioChannelState GetStateInternal(AudioChannel aChannel, uint64_t aChildID,
bool aElementHidden,
bool aElementWasHidden);
/* Update the internal type value following the visibility changes */
void UpdateChannelType(AudioChannelType aType, uint64_t aChildID,
void UpdateChannelType(AudioChannel aChannel, uint64_t aChildID,
bool aElementHidden, bool aElementWasHidden);
/* Send the default-volume-channel-changed notification */
void SetDefaultVolumeControlChannelInternal(AudioChannelType aType,
void SetDefaultVolumeControlChannelInternal(int32_t aChannel,
bool aHidden, uint64_t aChildID);
AudioChannelService();
@ -161,24 +167,22 @@ protected:
bool CheckVolumeFadedCondition(AudioChannelInternalType aType,
bool aElementHidden);
const char* ChannelName(AudioChannelType aType);
AudioChannelInternalType GetInternalType(AudioChannelType aType,
AudioChannelInternalType GetInternalType(AudioChannel aChannel,
bool aElementHidden);
class AudioChannelAgentData {
public:
AudioChannelAgentData(AudioChannelType aType,
AudioChannelAgentData(AudioChannel aChannel,
bool aElementHidden,
AudioChannelState aState,
bool aWithVideo)
: mType(aType)
: mChannel(aChannel)
, mElementHidden(aElementHidden)
, mState(aState)
, mWithVideo(aWithVideo)
{}
AudioChannelType mType;
AudioChannel mChannel;
bool mElementHidden;
AudioChannelState mState;
const bool mWithVideo;
@ -207,8 +211,8 @@ protected:
#endif
nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
AudioChannelType mCurrentHigherChannel;
AudioChannelType mCurrentVisibleHigherChannel;
int32_t mCurrentHigherChannel;
int32_t mCurrentVisibleHigherChannel;
nsTArray<uint64_t> mWithVideoChildIDs;

View File

@ -72,13 +72,15 @@ AudioChannelServiceChild::GetState(AudioChannelAgent* aAgent, bool aElementHidde
AudioChannelState state = AUDIO_CHANNEL_STATE_MUTED;
bool oldElementHidden = data->mElementHidden;
UpdateChannelType(data->mType, CONTENT_PROCESS_ID_MAIN, aElementHidden, oldElementHidden);
UpdateChannelType(data->mChannel, CONTENT_PROCESS_ID_MAIN, aElementHidden,
oldElementHidden);
// Update visibility.
data->mElementHidden = aElementHidden;
ContentChild* cc = ContentChild::GetSingleton();
cc->SendAudioChannelGetState(data->mType, aElementHidden, oldElementHidden, &state);
cc->SendAudioChannelGetState(data->mChannel, aElementHidden, oldElementHidden,
&state);
data->mState = state;
cc->SendAudioChannelChangedNotification();
@ -87,14 +89,12 @@ AudioChannelServiceChild::GetState(AudioChannelAgent* aAgent, bool aElementHidde
void
AudioChannelServiceChild::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannelType aType,
AudioChannel aChannel,
bool aWithVideo)
{
MOZ_ASSERT(aType != AUDIO_CHANNEL_DEFAULT);
AudioChannelService::RegisterAudioChannelAgent(aAgent, aChannel, aWithVideo);
AudioChannelService::RegisterAudioChannelAgent(aAgent, aType, aWithVideo);
ContentChild::GetSingleton()->SendAudioChannelRegisterType(aType, aWithVideo);
ContentChild::GetSingleton()->SendAudioChannelRegisterType(aChannel, aWithVideo);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
@ -117,7 +117,7 @@ AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
AudioChannelService::UnregisterAudioChannelAgent(aAgent);
ContentChild::GetSingleton()->SendAudioChannelUnregisterType(
data.mType, data.mElementHidden, data.mWithVideo);
data.mChannel, data.mElementHidden, data.mWithVideo);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
@ -132,11 +132,11 @@ AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
}
void
AudioChannelServiceChild::SetDefaultVolumeControlChannel(
AudioChannelType aType, bool aHidden)
AudioChannelServiceChild::SetDefaultVolumeControlChannel(int32_t aChannel,
bool aHidden)
{
ContentChild *cc = ContentChild::GetSingleton();
if (cc) {
cc->SendAudioChannelChangeDefVolChannel(aType, aHidden);
cc->SendAudioChannelChangeDefVolChannel(aChannel, aHidden);
}
}

View File

@ -31,7 +31,7 @@ public:
static void Shutdown();
virtual void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannelType aType,
AudioChannel aChannel,
bool aWithVideo);
virtual void UnregisterAudioChannelAgent(AudioChannelAgent* aAgent);
@ -42,7 +42,8 @@ public:
virtual AudioChannelState GetState(AudioChannelAgent* aAgent,
bool aElementHidden);
virtual void SetDefaultVolumeControlChannel(AudioChannelType aType, bool aHidden);
virtual void SetDefaultVolumeControlChannel(int32_t aChannel,
bool aHidden);
protected:
AudioChannelServiceChild();

View File

@ -31,8 +31,8 @@ class Agent : public nsIAudioChannelAgentCallback,
public:
NS_DECL_ISUPPORTS
Agent(AudioChannelType aType)
: mType(aType)
Agent(AudioChannel aChannel)
: mChannel(aChannel)
, mWaitCallback(false)
, mRegistered(false)
, mCanPlay(AUDIO_CHANNEL_STATE_MUTED)
@ -51,10 +51,12 @@ public:
{
nsresult rv = NS_OK;
if (video) {
rv = mAgent->InitWithVideo(nullptr, mType, this, true);
rv = mAgent->InitWithVideo(nullptr, static_cast<int32_t>(mChannel),
this, true);
}
else {
rv = mAgent->InitWithWeakCallback(nullptr, mType, this);
rv = mAgent->InitWithWeakCallback(nullptr, static_cast<int32_t>(mChannel),
this);
}
NS_ENSURE_SUCCESS(rv, rv);
@ -127,7 +129,7 @@ public:
}
nsCOMPtr<nsIAudioChannelAgent> mAgent;
AudioChannelType mType;
AudioChannel mChannel;
bool mWaitCallback;
bool mRegistered;
AudioChannelState mCanPlay;
@ -139,7 +141,7 @@ NS_IMPL_ISUPPORTS2(Agent, nsIAudioChannelAgentCallback,
nsresult
TestDoubleStartPlaying()
{
nsRefPtr<Agent> agent = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> agent = new Agent(AudioChannel::Normal);
nsresult rv = agent->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -158,7 +160,7 @@ TestDoubleStartPlaying()
nsresult
TestOneNormalChannel()
{
nsRefPtr<Agent> agent = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> agent = new Agent(AudioChannel::Normal);
nsresult rv = agent->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -182,11 +184,11 @@ TestOneNormalChannel()
nsresult
TestTwoNormalChannels()
{
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Normal);
nsresult rv = agent1->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Normal);
rv = agent2->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -223,11 +225,11 @@ TestTwoNormalChannels()
nsresult
TestContentChannels()
{
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_CONTENT);
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Content);
nsresult rv = agent1->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_CONTENT);
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Content);
rv = agent2->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -308,15 +310,15 @@ TestContentChannels()
nsresult
TestFadedState()
{
nsRefPtr<Agent> normalAgent = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> normalAgent = new Agent(AudioChannel::Normal);
nsresult rv = normalAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> contentAgent = new Agent(AUDIO_CHANNEL_CONTENT);
nsRefPtr<Agent> contentAgent = new Agent(AudioChannel::Content);
rv = contentAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> notificationAgent = new Agent(AUDIO_CHANNEL_NOTIFICATION);
nsRefPtr<Agent> notificationAgent = new Agent(AudioChannel::Notification);
rv = notificationAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -387,32 +389,32 @@ TestFadedState()
nsresult
TestPriorities()
{
nsRefPtr<Agent> normalAgent = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> normalAgent = new Agent(AudioChannel::Normal);
nsresult rv = normalAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> contentAgent = new Agent(AUDIO_CHANNEL_CONTENT);
nsRefPtr<Agent> contentAgent = new Agent(AudioChannel::Content);
rv = contentAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> notificationAgent = new Agent(AUDIO_CHANNEL_NOTIFICATION);
nsRefPtr<Agent> notificationAgent = new Agent(AudioChannel::Notification);
rv = notificationAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> alarmAgent = new Agent(AUDIO_CHANNEL_ALARM);
nsRefPtr<Agent> alarmAgent = new Agent(AudioChannel::Alarm);
rv = alarmAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> telephonyAgent = new Agent(AUDIO_CHANNEL_TELEPHONY);
nsRefPtr<Agent> telephonyAgent = new Agent(AudioChannel::Telephony);
rv = telephonyAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> ringerAgent = new Agent(AUDIO_CHANNEL_RINGER);
nsRefPtr<Agent> ringerAgent = new Agent(AudioChannel::Ringer);
rv = ringerAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> pNotificationAgent =
new Agent(AUDIO_CHANNEL_PUBLICNOTIFICATION);
new Agent(AudioChannel::Publicnotification);
rv = pNotificationAgent->Init();
NS_ENSURE_SUCCESS(rv, rv);
@ -544,11 +546,11 @@ TestPriorities()
nsresult
TestOneVideoNormalChannel()
{
nsRefPtr<Agent> agent1 = new Agent(AUDIO_CHANNEL_NORMAL);
nsRefPtr<Agent> agent1 = new Agent(AudioChannel::Normal);
nsresult rv = agent1->Init(true);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<Agent> agent2 = new Agent(AUDIO_CHANNEL_CONTENT);
nsRefPtr<Agent> agent2 = new Agent(AudioChannel::Content);
rv = agent2->Init(false);
NS_ENSURE_SUCCESS(rv, rv);
@ -649,11 +651,11 @@ int main(int argc, char** argv)
return 1;
}
// Channel type with AUDIO_CHANNEL_TELEPHONY cannot be unregistered until the
// Channel type with AudioChannel::Telephony cannot be unregistered until the
// main thread has chances to process 1500 millisecond timer. In order to
// skip ambiguous return value of ChannelsActiveWithHigherPriorityThan(), new
// test cases are added before any test case that registers the channel type
// with AUDIO_CHANNEL_TELEPHONY channel.
// with AudioChannel::Telephony channel.
if (NS_FAILED(TestOneVideoNormalChannel())) {
return 1;
}

View File

@ -8,5 +8,8 @@ CPP_UNIT_TESTS += [
'TestAudioChannelService.cpp',
]
if CONFIG['OS_ARCH'] == 'WINNT':
DEFINES['NOMINMAX'] = True
FAIL_ON_WARNINGS = True

View File

@ -699,7 +699,7 @@ nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions,
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
if (mAudioChannelAgent) {
// Camera app will stop recording when it falls to the background, so no callback is necessary.
mAudioChannelAgent->Init(mWindow, AUDIO_CHANNEL_CONTENT, nullptr);
mAudioChannelAgent->Init(mWindow, (int32_t)AudioChannel::Content, nullptr);
// Video recording doesn't output any sound, so it's not necessary to check canPlay.
int32_t canPlay;
mAudioChannelAgent->StartPlaying(&canPlay);

View File

@ -1899,7 +1899,7 @@ ContentParent::RecvFirstIdle()
}
bool
ContentParent::RecvAudioChannelGetState(const AudioChannelType& aType,
ContentParent::RecvAudioChannelGetState(const AudioChannel& aChannel,
const bool& aElementHidden,
const bool& aElementWasHidden,
AudioChannelState* aState)
@ -1908,33 +1908,33 @@ ContentParent::RecvAudioChannelGetState(const AudioChannelType& aType,
AudioChannelService::GetAudioChannelService();
*aState = AUDIO_CHANNEL_STATE_NORMAL;
if (service) {
*aState = service->GetStateInternal(aType, mChildID,
*aState = service->GetStateInternal(aChannel, mChildID,
aElementHidden, aElementWasHidden);
}
return true;
}
bool
ContentParent::RecvAudioChannelRegisterType(const AudioChannelType& aType,
ContentParent::RecvAudioChannelRegisterType(const AudioChannel& aChannel,
const bool& aWithVideo)
{
nsRefPtr<AudioChannelService> service =
AudioChannelService::GetAudioChannelService();
if (service) {
service->RegisterType(aType, mChildID, aWithVideo);
service->RegisterType(aChannel, mChildID, aWithVideo);
}
return true;
}
bool
ContentParent::RecvAudioChannelUnregisterType(const AudioChannelType& aType,
ContentParent::RecvAudioChannelUnregisterType(const AudioChannel& aChannel,
const bool& aElementHidden,
const bool& aWithVideo)
{
nsRefPtr<AudioChannelService> service =
AudioChannelService::GetAudioChannelService();
if (service) {
service->UnregisterType(aType, aElementHidden, mChildID, aWithVideo);
service->UnregisterType(aChannel, aElementHidden, mChildID, aWithVideo);
}
return true;
}
@ -1951,13 +1951,13 @@ ContentParent::RecvAudioChannelChangedNotification()
}
bool
ContentParent::RecvAudioChannelChangeDefVolChannel(
const AudioChannelType& aType, const bool& aHidden)
ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
const bool& aHidden)
{
nsRefPtr<AudioChannelService> service =
AudioChannelService::GetAudioChannelService();
if (service) {
service->SetDefaultVolumeControlChannelInternal(aType,
service->SetDefaultVolumeControlChannelInternal(aChannel,
aHidden, mChildID);
}
return true;

View File

@ -490,20 +490,20 @@ private:
virtual bool RecvFirstIdle() MOZ_OVERRIDE;
virtual bool RecvAudioChannelGetState(const AudioChannelType& aType,
virtual bool RecvAudioChannelGetState(const AudioChannel& aChannel,
const bool& aElementHidden,
const bool& aElementWasHidden,
AudioChannelState* aValue) MOZ_OVERRIDE;
virtual bool RecvAudioChannelRegisterType(const AudioChannelType& aType,
virtual bool RecvAudioChannelRegisterType(const AudioChannel& aChannel,
const bool& aWithVideo) MOZ_OVERRIDE;
virtual bool RecvAudioChannelUnregisterType(const AudioChannelType& aType,
virtual bool RecvAudioChannelUnregisterType(const AudioChannel& aChannel,
const bool& aElementHidden,
const bool& aWithVideo) MOZ_OVERRIDE;
virtual bool RecvAudioChannelChangedNotification() MOZ_OVERRIDE;
virtual bool RecvAudioChannelChangeDefVolChannel(const AudioChannelType& aType,
virtual bool RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
const bool& aHidden) MOZ_OVERRIDE;
virtual bool RecvBroadcastVolume(const nsString& aVolumeName) MOZ_OVERRIDE;

View File

@ -46,7 +46,7 @@ using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using mozilla::dom::asmjscache::OpenMode from "mozilla/dom/asmjscache/AsmJSCache.h";
using mozilla::dom::asmjscache::WriteParams from "mozilla/dom/asmjscache/AsmJSCache.h";
using mozilla::dom::AudioChannelType from "AudioChannelCommon.h";
using mozilla::dom::AudioChannel from "mozilla/dom/AudioChannelBinding.h";
using mozilla::dom::AudioChannelState from "AudioChannelCommon.h";
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
@ -515,18 +515,17 @@ parent:
async FirstIdle();
// Get Muted from the main AudioChannelService.
sync AudioChannelGetState(AudioChannelType aType, bool aElementHidden,
sync AudioChannelGetState(AudioChannel aChannel, bool aElementHidden,
bool aElementWasHidden)
returns (AudioChannelState value);
sync AudioChannelRegisterType(AudioChannelType aType, bool aWithVideo);
sync AudioChannelUnregisterType(AudioChannelType aType,
sync AudioChannelRegisterType(AudioChannel aChannel, bool aWithVideo);
sync AudioChannelUnregisterType(AudioChannel aChannel,
bool aElementHidden,
bool aWithVideo);
async AudioChannelChangedNotification();
async AudioChannelChangeDefVolChannel(AudioChannelType aType,
bool aHidden);
async AudioChannelChangeDefVolChannel(int32_t aChannel, bool aHidden);
async FilePathUpdateNotify(nsString aType,
nsString aStorageName,

View File

@ -8,6 +8,7 @@
#include "AudioChannelCommon.h"
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/AudioChannelBinding.h"
#include "nsIDOMEvent.h"
#include "nsCOMPtr.h"
@ -58,18 +59,40 @@ struct ParamTraits<mozilla::dom::RemoteDOMEvent>
}
};
template <>
struct ParamTraits<mozilla::dom::AudioChannelType>
: public EnumSerializer<mozilla::dom::AudioChannelType,
mozilla::dom::AUDIO_CHANNEL_DEFAULT,
mozilla::dom::AUDIO_CHANNEL_LAST>
{ };
template<>
struct ParamTraits<mozilla::dom::AudioChannel>
{
typedef mozilla::dom::AudioChannel paramType;
static bool IsLegalValue(const paramType &aValue) {
return aValue <= mozilla::dom::AudioChannel::Publicnotification;
}
static void Write(Message* aMsg, const paramType& aValue) {
MOZ_ASSERT(IsLegalValue(aValue));
WriteParam(aMsg, (uint32_t)aValue);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult) {
uint32_t value;
if(!ReadParam(aMsg, aIter, &value) ||
!IsLegalValue(paramType(value))) {
return false;
}
*aResult = paramType(value);
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
}
};
template <>
struct ParamTraits<mozilla::dom::AudioChannelState>
: public EnumSerializer<mozilla::dom::AudioChannelState,
mozilla::dom::AUDIO_CHANNEL_STATE_NORMAL,
mozilla::dom::AUDIO_CHANNEL_STATE_LAST>
mozilla::dom::AUDIO_CHANNEL_STATE_NORMAL,
mozilla::dom::AUDIO_CHANNEL_STATE_LAST>
{ };
}

View File

@ -25,7 +25,7 @@ NS_IMPL_RELEASE_INHERITED(AudioChannelManager, DOMEventTargetHelper)
AudioChannelManager::AudioChannelManager()
: mState(SWITCH_STATE_UNKNOWN)
, mVolumeChannel(AUDIO_CHANNEL_DEFAULT)
, mVolumeChannel(-1)
{
RegisterSwitchObserver(SWITCH_HEADPHONES, this);
mState = GetCurrentSwitchState(SWITCH_HEADPHONES);
@ -80,11 +80,10 @@ AudioChannelManager::SetVolumeControlChannel(const nsAString& aChannel)
return false;
}
AudioChannelType oldVolumeChannel = mVolumeChannel;
AudioChannel newChannel = AudioChannelService::GetAudioChannel(aChannel);
// Only normal channel doesn't need permission.
if (aChannel.EqualsASCII("normal")) {
mVolumeChannel = AUDIO_CHANNEL_NORMAL;
} else {
if (newChannel != AudioChannel::Normal) {
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
if (!permissionManager) {
@ -97,23 +96,14 @@ AudioChannelManager::SetVolumeControlChannel(const nsAString& aChannel)
if (perm != nsIPermissionManager::ALLOW_ACTION) {
return false;
}
if (aChannel.EqualsASCII("content")) {
mVolumeChannel = AUDIO_CHANNEL_CONTENT;
} else if (aChannel.EqualsASCII("notification")) {
mVolumeChannel = AUDIO_CHANNEL_NOTIFICATION;
} else if (aChannel.EqualsASCII("alarm")) {
mVolumeChannel = AUDIO_CHANNEL_ALARM;
} else if (aChannel.EqualsASCII("telephony")) {
mVolumeChannel = AUDIO_CHANNEL_TELEPHONY;
} else if (aChannel.EqualsASCII("ringer")) {
mVolumeChannel = AUDIO_CHANNEL_RINGER;
}
}
if (oldVolumeChannel == mVolumeChannel) {
if (mVolumeChannel == (int32_t)newChannel) {
return true;
}
mVolumeChannel = (int32_t)newChannel;
NotifyVolumeControlChannelChanged();
return true;
}
@ -121,18 +111,10 @@ AudioChannelManager::SetVolumeControlChannel(const nsAString& aChannel)
bool
AudioChannelManager::GetVolumeControlChannel(nsAString & aChannel)
{
if (mVolumeChannel == AUDIO_CHANNEL_NORMAL) {
aChannel.AssignASCII("normal");
} else if (mVolumeChannel == AUDIO_CHANNEL_CONTENT) {
aChannel.AssignASCII("content");
} else if (mVolumeChannel == AUDIO_CHANNEL_NOTIFICATION) {
aChannel.AssignASCII("notification");
} else if (mVolumeChannel == AUDIO_CHANNEL_ALARM) {
aChannel.AssignASCII("alarm");
} else if (mVolumeChannel == AUDIO_CHANNEL_TELEPHONY) {
aChannel.AssignASCII("telephony");
} else if (mVolumeChannel == AUDIO_CHANNEL_RINGER) {
aChannel.AssignASCII("ringer");
if (mVolumeChannel >= 0) {
AudioChannelService::GetAudioChannelString(
static_cast<AudioChannel>(mVolumeChannel),
aChannel);
} else {
aChannel.AssignASCII("");
}
@ -153,7 +135,7 @@ AudioChannelManager::NotifyVolumeControlChannelChanged()
if (isActive) {
service->SetDefaultVolumeControlChannel(mVolumeChannel, isActive);
} else {
service->SetDefaultVolumeControlChannel(AUDIO_CHANNEL_DEFAULT, isActive);
service->SetDefaultVolumeControlChannel(-1, isActive);
}
}

View File

@ -66,7 +66,7 @@ private:
void NotifyVolumeControlChannelChanged();
hal::SwitchState mState;
AudioChannelType mVolumeChannel;
int32_t mVolumeChannel;
};
} // namespace system

View File

@ -129,14 +129,17 @@ public:
int32_t volIndex = JSVAL_TO_INT(aResult);
if (aName.EqualsLiteral("audio.volume.content")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_CONTENT, volIndex);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Content,
volIndex);
} else if (aName.EqualsLiteral("audio.volume.notification")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_NOTIFICATION,
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Notification,
volIndex);
} else if (aName.EqualsLiteral("audio.volume.alarm")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_ALARM, volIndex);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Alarm,
volIndex);
} else if (aName.EqualsLiteral("audio.volume.telephony")) {
audioManager->SetAudioChannelVolume(AUDIO_CHANNEL_TELEPHONY, volIndex);
audioManager->SetAudioChannelVolume((int32_t)AudioChannel::Telephony,
volIndex);
} else if (aName.EqualsLiteral("audio.volume.bt_sco")) {
static_cast<AudioManager *>(audioManager.get())->SetStreamVolumeIndex(
AUDIO_STREAM_BLUETOOTH_SCO, volIndex);
@ -531,9 +534,9 @@ AudioManager::SetPhoneState(int32_t aState)
MOZ_ASSERT(mPhoneAudioAgent);
if (aState == PHONE_STATE_IN_CALL) {
// Telephony doesn't be paused by any other channels.
mPhoneAudioAgent->Init(nullptr, AUDIO_CHANNEL_TELEPHONY, nullptr);
mPhoneAudioAgent->Init(nullptr, (int32_t)AudioChannel::Telephony, nullptr);
} else {
mPhoneAudioAgent->Init(nullptr, AUDIO_CHANNEL_RINGER, nullptr);
mPhoneAudioAgent->Init(nullptr, (int32_t)AudioChannel::Ringer, nullptr);
}
// Telephony can always play.
@ -608,8 +611,8 @@ NS_IMETHODIMP
AudioManager::SetAudioChannelVolume(int32_t aChannel, int32_t aIndex) {
nsresult status;
switch (aChannel) {
case AUDIO_CHANNEL_CONTENT:
switch (static_cast<AudioChannel>(aChannel)) {
case AudioChannel::Content:
// sync FMRadio's volume with content channel.
if (IsDeviceOn(AUDIO_DEVICE_OUT_FM)) {
status = SetStreamVolumeIndex(AUDIO_STREAM_FM, aIndex);
@ -619,15 +622,15 @@ AudioManager::SetAudioChannelVolume(int32_t aChannel, int32_t aIndex) {
NS_ENSURE_SUCCESS(status, status);
status = SetStreamVolumeIndex(AUDIO_STREAM_SYSTEM, aIndex);
break;
case AUDIO_CHANNEL_NOTIFICATION:
case AudioChannel::Notification:
status = SetStreamVolumeIndex(AUDIO_STREAM_NOTIFICATION, aIndex);
NS_ENSURE_SUCCESS(status, status);
status = SetStreamVolumeIndex(AUDIO_STREAM_RING, aIndex);
break;
case AUDIO_CHANNEL_ALARM:
case AudioChannel::Alarm:
status = SetStreamVolumeIndex(AUDIO_STREAM_ALARM, aIndex);
break;
case AUDIO_CHANNEL_TELEPHONY:
case AudioChannel::Telephony:
status = SetStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, aIndex);
break;
default:
@ -643,21 +646,21 @@ AudioManager::GetAudioChannelVolume(int32_t aChannel, int32_t* aIndex) {
return NS_ERROR_NULL_POINTER;
}
switch (aChannel) {
case AUDIO_CHANNEL_CONTENT:
switch (static_cast<AudioChannel>(aChannel)) {
case AudioChannel::Content:
MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
mCurrentStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
*aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_MUSIC];
break;
case AUDIO_CHANNEL_NOTIFICATION:
case AudioChannel::Notification:
MOZ_ASSERT(mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
mCurrentStreamVolumeTbl[AUDIO_STREAM_RING]);
*aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION];
break;
case AUDIO_CHANNEL_ALARM:
case AudioChannel::Alarm:
*aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_ALARM];
break;
case AUDIO_CHANNEL_TELEPHONY:
case AudioChannel::Telephony:
*aIndex = mCurrentStreamVolumeTbl[AUDIO_STREAM_VOICE_CALL];
break;
default:
@ -674,21 +677,21 @@ AudioManager::GetMaxAudioChannelVolume(int32_t aChannel, int32_t* aMaxIndex) {
}
int32_t stream;
switch (aChannel) {
case AUDIO_CHANNEL_CONTENT:
switch (static_cast<AudioChannel>(aChannel)) {
case AudioChannel::Content:
MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_MUSIC] ==
sMaxStreamVolumeTbl[AUDIO_STREAM_SYSTEM]);
stream = AUDIO_STREAM_MUSIC;
break;
case AUDIO_CHANNEL_NOTIFICATION:
case AudioChannel::Notification:
MOZ_ASSERT(sMaxStreamVolumeTbl[AUDIO_STREAM_NOTIFICATION] ==
sMaxStreamVolumeTbl[AUDIO_STREAM_RING]);
stream = AUDIO_STREAM_NOTIFICATION;
break;
case AUDIO_CHANNEL_ALARM:
case AudioChannel::Alarm:
stream = AUDIO_STREAM_ALARM;
break;
case AUDIO_CHANNEL_TELEPHONY:
case AudioChannel::Telephony:
stream = AUDIO_STREAM_VOICE_CALL;
break;
default: