Bug 834200 - [Audio] Hook AudioManager::SetPhoneState for getting ring & in_call then register into AudioChannelService. r=baku, a=tef+

This commit is contained in:
Marco Chen 2013-02-04 11:23:06 +08:00
Родитель de6a8e9191
Коммит 2aa2cbcc4e
1 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -306,22 +306,26 @@ AudioManager::SetPhoneState(int32_t aState)
mPhoneState = aState; mPhoneState = aState;
if (aState == PHONE_STATE_IN_CALL) { if (mPhoneAudioAgent) {
if (!mPhoneAudioAgent) {
mPhoneAudioAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
MOZ_ASSERT(mPhoneAudioAgent);
// Telephony doesn't be paused by any other channels.
mPhoneAudioAgent->Init(AUDIO_CHANNEL_TELEPHONY, nullptr);
// Telephony can always play.
bool canPlay;
mPhoneAudioAgent->StartPlaying(&canPlay);
}
} else if (mPhoneAudioAgent) {
mPhoneAudioAgent->StopPlaying(); mPhoneAudioAgent->StopPlaying();
mPhoneAudioAgent = nullptr; mPhoneAudioAgent = nullptr;
} }
if (aState == PHONE_STATE_IN_CALL || aState == PHONE_STATE_RINGTONE) {
mPhoneAudioAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
MOZ_ASSERT(mPhoneAudioAgent);
if (aState == PHONE_STATE_IN_CALL) {
// Telephony doesn't be paused by any other channels.
mPhoneAudioAgent->Init(AUDIO_CHANNEL_TELEPHONY, nullptr);
} else {
mPhoneAudioAgent->Init(AUDIO_CHANNEL_RINGER, nullptr);
}
// Telephony can always play.
bool canPlay;
mPhoneAudioAgent->StartPlaying(&canPlay);
}
return NS_OK; return NS_OK;
} }