mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 1073494 - Audio is not routing to headset while playback is on BT. r=mwu
This commit is contained in:
parent
281cb8db91
commit
a380f2e081
@ -78,6 +78,7 @@ static int sMaxStreamVolumeTbl[AUDIO_STREAM_CNT] = {
|
||||
};
|
||||
// A bitwise variable for recording what kind of headset is attached.
|
||||
static int sHeadsetState;
|
||||
static bool sBluetoothA2dpEnabled;
|
||||
static const int kBtSampleRate = 8000;
|
||||
static bool sSwitchDone = true;
|
||||
static bool sA2dpSwitchDone = true;
|
||||
@ -290,7 +291,13 @@ AudioManager::HandleBluetoothStatusChanged(nsISupports* aSubject,
|
||||
cmd.setTo("A2dpSuspended=false");
|
||||
AudioSystem::setParameters(0, cmd);
|
||||
sA2dpSwitchDone = true;
|
||||
#if ANDROID_VERSION >= 17
|
||||
if (AudioSystem::getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_NO_BT_A2DP) {
|
||||
SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NONE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
sBluetoothA2dpEnabled = audioState == AUDIO_POLICY_DEVICE_STATE_AVAILABLE;
|
||||
} else if (!strcmp(aTopic, BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
|
||||
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
|
||||
audioState, aAddress.get());
|
||||
@ -396,6 +403,8 @@ NotifyHeadphonesStatus(SwitchState aState)
|
||||
class HeadphoneSwitchObserver : public SwitchObserver
|
||||
{
|
||||
public:
|
||||
HeadphoneSwitchObserver(AudioManager* aAudioManager)
|
||||
: mAudioManager(aAudioManager) { }
|
||||
void Notify(const SwitchEvent& aEvent) {
|
||||
NotifyHeadphonesStatus(aEvent.status());
|
||||
// When user pulled out the headset, a delay of routing here can avoid the leakage of audio from speaker.
|
||||
@ -407,12 +416,24 @@ public:
|
||||
InternalSetAudioRoutes(aEvent.status());
|
||||
sSwitchDone = true;
|
||||
}
|
||||
// Handle the coexistence of a2dp / headset device, latest one wins.
|
||||
#if ANDROID_VERSION >= 17
|
||||
int32_t forceUse = 0;
|
||||
mAudioManager->GetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, &forceUse);
|
||||
if (aEvent.status() != SWITCH_STATE_OFF && sBluetoothA2dpEnabled) {
|
||||
mAudioManager->SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NO_BT_A2DP);
|
||||
} else if (forceUse == AUDIO_POLICY_FORCE_NO_BT_A2DP) {
|
||||
mAudioManager->SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NONE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
AudioManager* mAudioManager;
|
||||
};
|
||||
|
||||
AudioManager::AudioManager()
|
||||
: mPhoneState(PHONE_STATE_CURRENT)
|
||||
, mObserver(new HeadphoneSwitchObserver())
|
||||
, mObserver(new HeadphoneSwitchObserver(this))
|
||||
#ifdef MOZ_B2G_RIL
|
||||
, mMuteCallToRIL(false)
|
||||
#endif
|
||||
|
@ -42,12 +42,9 @@ typedef enum {
|
||||
AUDIO_POLICY_FORCE_WIRED_ACCESSORY,
|
||||
AUDIO_POLICY_FORCE_BT_CAR_DOCK,
|
||||
AUDIO_POLICY_FORCE_BT_DESK_DOCK,
|
||||
|
||||
#ifdef VANILLA_ANDROID
|
||||
AUDIO_POLICY_FORCE_ANALOG_DOCK,
|
||||
AUDIO_POLICY_FORCE_DIGITAL_DOCK,
|
||||
#endif
|
||||
|
||||
AUDIO_POLICY_FORCE_NO_BT_A2DP,
|
||||
AUDIO_POLICY_FORCE_CFG_CNT,
|
||||
AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1,
|
||||
|
||||
@ -724,6 +721,9 @@ public:
|
||||
FORCE_WIRED_ACCESSORY,
|
||||
FORCE_BT_CAR_DOCK,
|
||||
FORCE_BT_DESK_DOCK,
|
||||
FORCE_ANALOG_DOCK,
|
||||
FORCE_DIGITAL_DOCK,
|
||||
FORCE_NO_BT_A2DP,
|
||||
NUM_FORCE_CONFIG,
|
||||
FORCE_DEFAULT = FORCE_NONE
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ interface nsIAudioManager : nsISupports
|
||||
* Are we playing audio from the FM radio?
|
||||
*/
|
||||
attribute boolean fmRadioAudioEnabled;
|
||||
|
||||
|
||||
/**
|
||||
* Set the phone's audio mode.
|
||||
*/
|
||||
@ -41,7 +41,9 @@ interface nsIAudioManager : nsISupports
|
||||
const long FORCE_WIRED_ACCESSORY = 5;
|
||||
const long FORCE_BT_CAR_DOCK = 6;
|
||||
const long FORCE_BT_DESK_DOCK = 7;
|
||||
|
||||
const long FORCE_ANALOG_DOCK = 8;
|
||||
const long FORCE_DIGITAL_DOCK = 9;
|
||||
const long FORCE_NO_BT_A2DP = 10;
|
||||
const long USE_COMMUNICATION = 0;
|
||||
const long USE_MEDIA = 1;
|
||||
const long USE_RECORD = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user