Bug 815322 - Phone rings on incoming call will pause audio. r=kinetik, a=blocking-basecamp

1. Add a new audio channel type called ringer.
  2. Add logic into AudioChannelService for ringer.
This commit is contained in:
Marco Chen 2012-12-06 17:11:19 +08:00
parent 07ef80f1ed
commit fa2305ecd5
7 changed files with 16 additions and 3 deletions

View File

@ -1960,6 +1960,7 @@ bool nsHTMLMediaElement::ParseAttribute(int32_t aNamespaceID,
{ "notification", AUDIO_CHANNEL_NOTIFICATION },
{ "alarm", AUDIO_CHANNEL_ALARM },
{ "telephony", AUDIO_CHANNEL_TELEPHONY },
{ "ringer", AUDIO_CHANNEL_RINGER },
{ "publicnotification", AUDIO_CHANNEL_PUBLICNOTIFICATION },
{ 0 }
};

View File

@ -166,6 +166,8 @@ static sa_stream_type_t ConvertChannelToSAType(dom::AudioChannelType aType)
return SA_STREAM_TYPE_ALARM;
case dom::AUDIO_CHANNEL_TELEPHONY:
return SA_STREAM_TYPE_VOICE_CALL;
case dom::AUDIO_CHANNEL_RINGER:
return SA_STREAM_TYPE_RING;
case dom::AUDIO_CHANNEL_PUBLICNOTIFICATION:
return SA_STREAM_TYPE_ENFORCED_AUDIBLE;
default:

View File

@ -18,6 +18,7 @@ enum AudioChannelType {
AUDIO_CHANNEL_NOTIFICATION,
AUDIO_CHANNEL_ALARM,
AUDIO_CHANNEL_TELEPHONY,
AUDIO_CHANNEL_RINGER,
AUDIO_CHANNEL_PUBLICNOTIFICATION,
AUDIO_CHANNEL_LAST
};

View File

@ -145,6 +145,7 @@ AudioChannelService::GetMuted(AudioChannelType aType, bool aElementHidden)
case AUDIO_CHANNEL_NOTIFICATION:
case AUDIO_CHANNEL_ALARM:
case AUDIO_CHANNEL_TELEPHONY:
case AUDIO_CHANNEL_RINGER:
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
// Nothing to do
break;
@ -164,11 +165,13 @@ AudioChannelService::GetMuted(AudioChannelType aType, bool aElementHidden)
muted = !!mChannelCounters[AUDIO_CHANNEL_NOTIFICATION] ||
!!mChannelCounters[AUDIO_CHANNEL_ALARM] ||
!!mChannelCounters[AUDIO_CHANNEL_TELEPHONY] ||
!!mChannelCounters[AUDIO_CHANNEL_RINGER] ||
!!mChannelCounters[AUDIO_CHANNEL_PUBLICNOTIFICATION];
case AUDIO_CHANNEL_NOTIFICATION:
case AUDIO_CHANNEL_ALARM:
case AUDIO_CHANNEL_TELEPHONY:
case AUDIO_CHANNEL_RINGER:
muted = ChannelsActiveWithHigherPriorityThan(aType);
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
@ -262,6 +265,7 @@ AudioChannelService::ChannelName(AudioChannelType aType)
{ AUDIO_CHANNEL_NOTIFICATION, "notification" },
{ AUDIO_CHANNEL_ALARM, "alarm" },
{ AUDIO_CHANNEL_TELEPHONY, "telephony" },
{ AUDIO_CHANNEL_RINGER, "ringer" },
{ AUDIO_CHANNEL_PUBLICNOTIFICATION, "publicnotification" },
{ -1, "unknown" }
};

View File

@ -20,7 +20,7 @@
* @status UNDER_DEVELOPMENT
*/
[scriptable, uuid(5215662f-9ab5-4219-adb1-672b870b08ba)]
[scriptable, uuid(ee5df17c-3928-11e2-8808-10bf48d64bd4)]
interface nsIDOMHTMLAudioElement : nsIDOMHTMLMediaElement
{
// Setup the audio stream for writing

View File

@ -27,7 +27,7 @@ interface nsIDOMMediaStream;
#endif
%}
[scriptable, uuid(75ccaaec-6920-43ae-a56f-ee7a693f3d31)]
[scriptable, uuid(d9331886-3928-11e2-b0e1-10bf48d64bd4)]
interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
{
// error state
@ -136,11 +136,16 @@ interface nsIDOMHTMLMediaElement : nsIDOMHTMLElement
// played.
// User case: Alarm clock, calendar alarms
// * telephony
// Automatically paused if "ringer" or higher priority
// channel is played.
// Use case: dialer, voip
// * ringer
// Automatically paused if "publicnotification" or higher priority
// channel is played.
// Use case: dialer, voip
// * publicnotification
// Always plays in speaker, even when headphones are plugged in.
// Use case: Camera shutter sound.
attribute DOMString mozAudioChannelType;
// In addition the media element has this new events:

View File

@ -16,7 +16,7 @@
* @status UNDER_DEVELOPMENT
*/
[scriptable, uuid(5f33df40-25d7-4d7b-9b2f-0b9acd9e5ad7)]
[scriptable, uuid(fe914e4a-3928-11e2-bea2-10bf48d64bd4)]
interface nsIDOMHTMLVideoElement : nsIDOMHTMLMediaElement
{
attribute long width;