Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
livekitAndroidXuningTest
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
davidliu
2023-07-16 23:21:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-07-16 23:21:19 +0900
Commit
90648076f8d0b490ee3e3789b4482dc3108cf3cd
90648076
1 parent
430f3b06
Fix bluetooth mic not being used when no other audio is playing (#244)
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
49 行增加
和
1 行删除
livekit-android-sdk/src/main/java/io/livekit/android/audio/AudioSwitchHandler.kt
livekit-android-sdk/src/main/java/io/livekit/android/audio/AudioSwitchHandler.kt
查看文件 @
9064807
package io.livekit.android.audio
import android.content.Context
import android.media.AudioDeviceInfo
import android.media.AudioManager
import android.os.Build
import android.os.Handler
...
...
@@ -74,7 +75,54 @@ constructor(private val context: Context) : AudioHandler {
)
}
audioSwitch = switch
switch.start(audioDeviceChangeListener ?: defaultAudioDeviceChangeListener)
switch.start { audioDevices: List<AudioDevice>, selectedAudioDevice: AudioDevice? ->
// On >S, some devices don't properly use bluetooth mic if no audio tracks.
// Using the new communication devices api fixes this.
// TODO: Move into AudioSwitch itself
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
val commDevices = audioManager.availableCommunicationDevices
val audioDeviceInfo = when (selectedAudioDevice) {
is AudioDevice.BluetoothHeadset -> {
commDevices.firstOrNull { info ->
info.type == AudioDeviceInfo.TYPE_BLUETOOTH_SCO || info.type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
}
}
is AudioDevice.Earpiece -> {
commDevices.firstOrNull { info ->
info.type == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE
}
}
is AudioDevice.Speakerphone -> {
commDevices.firstOrNull { info ->
info.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER
}
}
is AudioDevice.WiredHeadset -> {
commDevices.firstOrNull { info ->
info.type == AudioDeviceInfo.TYPE_WIRED_HEADSET || info.type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
}
}
else -> {
null
}
}
if (audioDeviceInfo != null) {
audioManager.setCommunicationDevice(audioDeviceInfo)
} else {
audioManager.clearCommunicationDevice()
}
}
audioDeviceChangeListener?.invoke(audioDevices, selectedAudioDevice)
}
switch.activate()
}
}
...
...
请
注册
或
登录
后发表评论