mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 819858 - Add AudioChannelAgent to AudioManager for telephony joining AudioChannelService. r=baku, a=blocking-basecamp
This commit is contained in:
parent
345efe131e
commit
fdd19173a2
@ -299,17 +299,3 @@ AudioChannelService::ChannelName(AudioChannelType aType)
|
||||
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
|
||||
|
||||
|
@ -52,13 +52,6 @@ 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();
|
||||
|
||||
|
@ -294,17 +294,32 @@ AudioManager::GetPhoneState(int32_t* aState)
|
||||
NS_IMETHODIMP
|
||||
AudioManager::SetPhoneState(int32_t aState)
|
||||
{
|
||||
if (mPhoneState == aState) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (AudioSystem::setPhoneState(aState)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mPhoneState = aState;
|
||||
|
||||
nsRefPtr<AudioChannelService> audioChannelService = AudioChannelService::GetAudioChannelService();
|
||||
if (!audioChannelService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aState == PHONE_STATE_IN_CALL) {
|
||||
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);
|
||||
}
|
||||
audioChannelService->SetPhoneInCall(aState == nsIAudioManager::PHONE_STATE_IN_CALL);
|
||||
} else if (mPhoneAudioAgent) {
|
||||
mPhoneAudioAgent->StopPlaying();
|
||||
mPhoneAudioAgent = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,14 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIAudioManager.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "AudioChannelAgent.h"
|
||||
|
||||
// {b2b51423-502d-4d77-89b3-7786b562b084}
|
||||
#define NS_AUDIOMANAGER_CID {0x94f6fd70, 0x7615, 0x4af9, \
|
||||
{0x89, 0x10, 0xf9, 0x3c, 0x55, 0xe6, 0x62, 0xec}}
|
||||
#define NS_AUDIOMANAGER_CONTRACTID "@mozilla.org/telephony/audiomanager;1"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal {
|
||||
@ -52,6 +54,7 @@ protected:
|
||||
|
||||
private:
|
||||
nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
|
||||
nsCOMPtr<AudioChannelAgent> mPhoneAudioAgent;
|
||||
bool mFMChannelIsMuted;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user