Created
January 16, 2020 13:00
-
-
Save halilozercan/05721673692e1748cd90b57940e75625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias OnAudioDeviceChanged = ( | |
selectedAudioDevice: AudioGenie.AudioDevice?, | |
availableAudioDevices: Set<AudioGenie.AudioDevice> | |
) -> Unit | |
val newAudioDevices: MutableSet<AudioDevice> = HashSet() | |
if (bluetoothManager.state == State.SCO_CONNECTED || bluetoothManager.state == State.SCO_CONNECTING || bluetoothManager.state == State.HEADSET_AVAILABLE | |
) { | |
newAudioDevices.add(AudioDevice.BLUETOOTH) | |
} | |
if (hasWiredHeadset) { | |
// If a wired headset is connected, then it is the only possible option. | |
newAudioDevices.add(AudioDevice.WIRED_HEADSET) | |
} else { | |
// No wired headset, hence the audio-device list can contain speaker // phone (on a tablet), or speaker phone and earpiece (on mobile phone). | |
newAudioDevices.add(AudioDevice.SPEAKER_PHONE) | |
if (hasEarpiece()) { | |
newAudioDevices.add(AudioDevice.EARPIECE) | |
} | |
} | |
// Store state which is set to true if the device list has changed. | |
var audioDeviceSetUpdated = audioDevices != newAudioDevices | |
// Update the existing audio device set. | |
audioDevices = newAudioDevices | |
… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment