mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860584 - [Buri][ACC] Speaker sound when plug out earphone. r=mchen
This commit is contained in:
parent
120cca3ff5
commit
8c0ad3514e
@ -23,6 +23,7 @@
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "base/message_loop.h"
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothProfileManagerBase.h"
|
||||
@ -60,6 +61,7 @@ static int sMaxStreamVolumeTbl[AUDIO_STREAM_CNT] = {
|
||||
// A bitwise variable for recording what kind of headset is attached.
|
||||
static int sHeadsetState;
|
||||
static const int kBtSampleRate = 8000;
|
||||
static bool sSwitchDone = true;
|
||||
|
||||
class RecoverTask : public nsRunnable
|
||||
{
|
||||
@ -116,6 +118,14 @@ IsDeviceOn(audio_devices_t device)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ProcessDelayedAudioRoute(SwitchState aState)
|
||||
{
|
||||
if (sSwitchDone)
|
||||
return;
|
||||
InternalSetAudioRoutes(aState);
|
||||
sSwitchDone = true;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(AudioManager, nsIAudioManager, nsIObserver)
|
||||
|
||||
static AudioSystem::audio_devices
|
||||
@ -269,8 +279,16 @@ class HeadphoneSwitchObserver : public SwitchObserver
|
||||
{
|
||||
public:
|
||||
void Notify(const SwitchEvent& aEvent) {
|
||||
InternalSetAudioRoutes(aEvent.status());
|
||||
NotifyHeadphonesStatus(aEvent.status());
|
||||
// When user pulled out the headset, a delay of routing here can avoid the leakage of audio from speaker.
|
||||
if (aEvent.status() == SWITCH_STATE_OFF && sSwitchDone) {
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE, NewRunnableFunction(&ProcessDelayedAudioRoute, SWITCH_STATE_OFF), 1000);
|
||||
sSwitchDone = false;
|
||||
} else if (aEvent.status() != SWITCH_STATE_OFF) {
|
||||
InternalSetAudioRoutes(aEvent.status());
|
||||
sSwitchDone = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user