wildfirechat / android-chat

即时通讯,聊天,野火IMAndroid客户端,支持Android 4.x —— 最新
http://docs.wildfirechat.cn
Other
2.54k stars 889 forks source link

harmonyOS #642

Closed fly2021031 closed 2 years ago

fly2021031 commented 2 years ago

提issue小提示

harmonyOS 系统,语音通话喇叭点击没有效果,所有的harmonyOS系统都是这个情况

操作说明

互相拨打语音,第一次点击喇叭按钮状态改变了,但是声音一直是外放的,无法切换到听筒播放

表现现象

自动切换到AVAudioManager.AudioDevice.SPEAKER_PHONE

预期结果

关闭喇叭时,需要能正常切换到听筒

补充条件

最新版本,必现,所有的harmonyOS 系统

demo对比结果

使用的demo测试

imndx commented 2 years ago

你好,是用源码编译测试的,还是用我们发布的最新 demo 测试的?

fly2021031 commented 2 years ago

用源码编译测试的

imndx commented 2 years ago

我用 HarmonyOS 2.0.0 测试,没法复现问题。

fly2021031 commented 2 years ago

我刚刚用最新master代码测试不行哦

fly2021031 commented 2 years ago

https://user-images.githubusercontent.com/101697019/160222749-29e43dd5-15b7-4830-8050-239c1e8fecb8.mp4

imndx commented 2 years ago

请你用我们发布的最新 apk 测试一下,因为音视频 SDK 版本不一样,我们想对比下。

https://github.com/wildfirechat/android-chat/releases

fly2021031 commented 2 years ago

下载的0.9.4版本的apk,情况是一样的

imndx commented 2 years ago

请你 debug 下吧,找到 SingleAudioFragment#speakerClick,然后打断点调试下是为什么不能切换。

fly2021031 commented 2 years ago

2022-03-26 14:01:12.762 19585-19585/cn.wildfirechat.chat V/AudioManager: querySoundEffectsEnabled... 2022-03-26 14:01:14.528 19585-19585/cn.wildfirechat.chat D/AVAudioManager: --- updateAudioDeviceState: wired headset=false, BT state=HEADSET_UNAVAILABLE 2022-03-26 14:01:14.528 19585-19585/cn.wildfirechat.chat D/AVAudioManager: Device status: available=[SPEAKER_PHONE, EARPIECE], selected=SPEAKER_PHONE, user selected=EARPIECE 2022-03-26 14:01:14.530 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=EARPIECE) 2022-03-26 14:01:14.531 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:14.532 19585-19585/cn.wildfirechat.chat I/AudioManager: setSpeakerphoneOn: false 2022-03-26 14:01:14.540 19585-19585/cn.wildfirechat.chat D/AVAudioManager: New device status: available=[SPEAKER_PHONE, EARPIECE], selected=EARPIECE 2022-03-26 14:01:14.540 19585-19585/cn.wildfirechat.chat D/ddd: onAudioManagerDevicesChanged: [SPEAKER_PHONE, EARPIECE], selected: EARPIECE 2022-03-26 14:01:14.541 19585-19585/cn.wildfirechat.chat D/AVAudioManager: --- updateAudioDeviceState done 2022-03-26 14:01:14.541 19585-19585/cn.wildfirechat.chat I/Choreographer: Skipped 106 frames! The application may be doing too much work on its main thread. 2022-03-26 14:01:14.750 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:14.750 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:14.752 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: false 2022-03-26 14:01:14.752 19585-19585/cn.wildfirechat.chat I/AudioManager: setSpeakerphoneOn: true 2022-03-26 14:01:14.760 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569595283219, distance=5.0 2022-03-26 14:01:14.828 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:14.829 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:14.830 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:14.830 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569675283219, distance=5.0 2022-03-26 14:01:14.911 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:14.911 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:14.912 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:14.913 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569755284782, distance=5.0 2022-03-26 14:01:14.989 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:14.989 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:14.990 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:14.991 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569835284782, distance=5.0 2022-03-26 14:01:15.069 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:15.069 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:15.070 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:15.071 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569915283219, distance=5.0 2022-03-26 14:01:15.150 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:15.151 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:15.151 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:15.153 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458569995284782, distance=5.0 2022-03-26 14:01:15.230 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: Proximity sensor => FAR state 2022-03-26 14:01:15.231 19585-19585/cn.wildfirechat.chat D/AVAudioManager: setAudioDeviceInternal(device=SPEAKER_PHONE) 2022-03-26 14:01:15.232 19585-19585/cn.wildfirechat.chat V/AudioManager: isSpeakerphoneOn: true 2022-03-26 14:01:15.234 19585-19585/cn.wildfirechat.chat D/AVProximitySensor: onSensorChanged@[name=main, id=1]: accuracy=3, timestamp=6458570075284782, distance=5.0 2022-03-26 14:01:16.803 19585-20258/cn.wildfirechat.chat I/remote_ntp_time_estimator.cc: (line 86): RTP timestamp: 1911170758 in NTP clock: 3857263275422 estimated time in receiver NTP clock: 3857263276654 2022-03-26 14:01:17.687 19585-20257/cn.wildfirechat.chat V/AudioManager: getMode... 2022-03-26 14:01:17.688 19585-20257/cn.wildfirechat.chat V/AudioManager: getStreamVolume streamType: 0 volume: 15 2022-03-26 14:01:17.688 19585-20257/cn.wildfirechat.chat I/VolumeLogger: VOICE_CALL stream volume: 15 (max=15) 2022-03-26 14:01:17.742 19585-20248/cn.wildfirechat.chat I/audio_device_buffer.cc: (line 414): [REC : 10010msec, 48kHz] callbacks: 1000, samples: 480000, rate: 47952, rate diff: 0%, level: 203 2022-03-26 14:01:17.743 19585-20248/cn.wildfirechat.chat I/audio_device_buffer.cc: (line 440): [PLAY: 10010msec, 48kHz] callbacks: 998, samples: 479040, rate: 47856, rate diff: 0%, level: 364 2022-03-26 14:01:17.822 19585-20259/cn.wildfirechat.chat I/NetworkMonitorAutoDetect: Network 579 is disconnected 2022-03-26 14:01:17.823 19585-20259/cn.wildfirechat.chat I/android_network_monitor.cc: (line 400): Network disconnected for handle 2490191761421 2022-03-26 14:01:17.854 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 111): Filtered out ignored networks: 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 113): Net[lo:0:0:0:x:x:x:x:x/128:Loopback:id=2] 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 113): Net[lo:127.0.0.x/8:Loopback:id=1] 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 846): Prune 2 ports because their networks were gone 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/p2p_transport_channel.cc: (line 2084): Removed port: Port[4c06c000:audio:1:0:local:Net[rmnet0:100.88.53.x/32:Cellular:id=4]] 1 remaining 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 1214): Removed 2 candidates 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 111): Filtered out ignored networks: 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 113): Net[lo:0:0:0:x:x:x:x:x/128:Loopback:id=2] 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 113): Net[lo:127.0.0.x/8:Loopback:id=1] 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 776): Allocate ports on 1 networks 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/port.cc: (line 895): Port[4c072000:audio:1:0:relay:Net[rmnet0:100.88.53.x/32:Cellular:id=4]]: Port deleted 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/basic_port_allocator.cc: (line 1160): Port[4c072000:audio:1:0:relay:Net[rmnet0:100.88.53.x/32:Cellular:id=4]]: Removed port from allocator (3 remaining) 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat E/turn_port.cc: (line 848): Port[4c072000:audio:1:0:relay:Net[rmnet0:100.88.53.x/32:Cellular:id=4]]: Failed to send TURN message, error: 101 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat I/turn_port.cc: (line 1554): Port[4c072000:audio:1:0:relay:Net[rmnet0:100.88.53.x/32:Cellular:id=4]]: TURN refresh request sent, id=4c6777643466523730725359 2022-03-26 14:01:17.855 19585-20244/cn.wildfirechat.chat W/thread.cc: (line 803): Waiting for the thread to join, but blocking calls have been disallowed 2022-03-26 14:01:17.860 19585-19585/cn.wildfirechat.chat D/CallRTCClient: send message prepared 2022-03-26 14:01:17.873 19585-19585/cn.wildfirechat.chat D/CallRTCClient: send message success

fly2021031 commented 2 years ago

这是点击喇叭按钮的日志

imndx commented 2 years ago

这个问题是距离传感器处理逻辑不太对导致的,后续,我们将参考微信的处理逻辑进行处理。

微信的处理逻辑如下:

  1. 只有一对一语音通话,可以开启距离传感器
  2. 一对一语音通话时,距离传感器默认关闭。当用户手动开启麦克风,然后关闭麦克风时,开启距离传感器
  3. 距离传感器开启后,不会触发音频输出设备的改变,只会触发息屏。