Bug 815445 - Hook up telephony audio to audio channels backend r=baku

This commit is contained in:
rlin@mozilla.com 2012-12-06 18:11:06 +08:00
Родитель 46765f45a1
Коммит 0a416b2ed2
3 изменённых файлов: 32 добавлений и 0 удалений

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

@ -20,6 +20,9 @@
#include "nsThreadUtils.h"
#ifdef MOZ_WIDGET_GONK
#include "nsIAudioManager.h"
#endif
using namespace mozilla;
using namespace mozilla::dom;
@ -273,3 +276,18 @@ AudioChannelService::ChannelName(AudioChannelType aType)
NS_NOTREACHED("Execution should not reach here!");
return nullptr;
}
#ifdef MOZ_WIDGET_GONK
void
AudioChannelService::SetPhoneInCall(bool aActive)
{
//while ring tone and in-call mode, mute media element
if (aActive) {
mChannelCounters[AUDIO_CHANNEL_TELEPHONY] = 1;
} else {
mChannelCounters[AUDIO_CHANNEL_TELEPHONY] = 0;
}
Notify();
}
#endif

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

@ -51,6 +51,13 @@ public:
*/
virtual bool GetMuted(AudioChannelType aType, bool aElementHidden);
/**
* Sync the phone status with telephony
*/
#ifdef MOZ_WIDGET_GONK
void SetPhoneInCall(bool aActive);
#endif
protected:
void Notify();

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

@ -20,6 +20,7 @@
#include "gonk/AudioSystem.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "AudioChannelService.h"
using namespace mozilla::dom::gonk;
using namespace android;
@ -298,6 +299,12 @@ AudioManager::SetPhoneState(int32_t aState)
}
mPhoneState = aState;
nsRefPtr<AudioChannelService> audioChannelService = AudioChannelService::GetAudioChannelService();
if (!audioChannelService) {
return NS_ERROR_FAILURE;
}
audioChannelService->SetPhoneInCall(aState == nsIAudioManager::PHONE_STATE_IN_CALL);
return NS_OK;
}