ios端, 通话中有device提醒之后AudioSession问题

Open
#81 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
dart, ios

Research direction

Start by reproducing the interruption scenario with the reported Flutter and iOS versions, then trace the audio-session handling in audio_device_ios.mm, TXCAudioSessionManager.mm, and audio_unit_wrapper.mm. Use the reported AudioUnit error and repeated restart logs to identify the failure path; done means the call resumes audio after the alarm without repeated initialization failures or warning 1204 events.

Written by the indexing model from the issue text.

Description

您好,我在用TRTC的电话功能,
在iOS的device下打电话中,有Alarm之后,拿回来AudioSession的动作看起来有问题。
如下有 Flutter doctor 与 当时出来的Error。
麻烦您们看一下
谢谢。

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.2.1 23C71 darwin-arm64 (Rosetta), locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.85.1)
[✓] Connected device (6 available)
[✓] Network resources

tencent_trtc_cloud: ^2.5.9

[I][01-10/15:23:11.502+9.0][4784,107779][audio_device_ios.mm:1181]AudioDeviceIOS OnAudioSessionInterruptionBegin
[I][01-10/15:23:11.504+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[I][01-10/15:23:11.515+9.0][4784,109315][trtc_pipeline.cc:3815][39c0]AudioDevice: interrupted by another audio session
[I][01-10/15:23:11.553+9.0][4784,259][TXCAudioSessionManager.mm:241]AudioSession RouteChange NSConcreteNotification 0x283c832e0 {name = AVAudioSessionRouteChangeNotification; object = <AVAudioSession: 0x283fe5c00>; userInfo = {
    AVAudioSessionRouteChangePreviousRouteKey = "<AVAudioSessionRouteDescription: 0x283ff9c90, \ninputs = (\n    \"<AVAudioSessionPortDescription: 0x283ffbda0, type = MicrophoneBuiltIn; name = iPhone \\Ub9c8\\Uc774\\Ud06c; UID = Built-In Microphone; selectedDataSource = \\Ud558\\Ub2e8>\"\n); \noutputs = (\n    \"<AVAudioSessionPortDescription: 0x283ffbcd0, type = Speaker; name = \\Uc2a4\\Ud53c\\Ucee4; UID = Speaker; selectedDataSource = (null)>\"\n)>";
    AVAudioSessionRouteChangeReasonKey = 3;
}}
[I][01-10/15:23:11.994+9.0][4784,107779][audio_device_ios.mm:1375]OnAudioSessionOtherAppPlayoutStateChanged is_playing=1
[I][01-10/15:23:11.995+9.0][4784,109315][trtc_pipeline.cc:3863][39c0]AudioDevice: other app start playing(iOS)
[I][01-10/15:23:14.227+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1040
[I][01-10/15:23:14.616+9.0][4784,259][TXCAudioSessionManager.mm:203]AudioSession Interrupt NSConcreteNotification 0x283c847c0 {name = AVAudioSessionInterruptionNotification; object = <AVAudioSession: 0x283fe5c00>; userInfo = {
    AVAudioSessionInterruptionOptionKey = 1;
    AVAudioSessionInterruptionTypeKey = 0;
}}
[I][01-10/15:23:14.616+9.0][4784,107779][audio_device_ios.mm:1193]AudioDeviceIOS OnAudioSessionInterruptionEnd shouldResume 1
[I][01-10/15:23:14.616+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[I][01-10/15:23:14.616+9.0][4784,107779][ear_monitoring.cc:160]Clear EarMonitoring buffer
[I][01-10/15:23:14.619+9.0][4784,107779][audio_device_ios.mm:733]StartAudioUnit need_record=1 expect_route=kSpeakerPhone need_voip=1
[W][01-10/15:23:14.629+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:14.629+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[W][01-10/15:23:14.731+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:14.731+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[I][01-10/15:23:14.833+9.0][4784,107779][audio_device_ios.mm:744]StartAudioUnit done. initialize audio unit failed with system error1701737535.
[I][01-10/15:23:14.834+9.0][4784,107779][audio_device_ios.mm:758]StartAudioUnit hardware input gain: 1.0
[I][01-10/15:23:14.834+9.0][4784,107779][scoped_duration_calculator.cc:23]StartAudioUnit cost 215ms
[I][01-10/15:23:14.842+9.0][4784,109315][trtc_pipeline.cc:3832][39c0]AudioDevice: restart play device failed because of resuming from interruption. system error:1701737535. initialize audio unit failed. category:AVAudioSessionCategoryPlayAndRecord, options:13, mode:AVAudioSessionModeVoiceChat, hardware sample rate:48000, IO duration: 0.0213333, other APP is playing, playout volume[5] is too low, system in VOIP mode, play device:kSpeakerPhone
[I][01-10/15:23:15.992+9.0][4784,107779][audio_device_ios.mm:1375]OnAudioSessionOtherAppPlayoutStateChanged is_playing=0
[I][01-10/15:23:15.993+9.0][4784,109315][trtc_pipeline.cc:3863][39c0]AudioDevice: other app stop playing(iOS)
[I][01-10/15:23:16.413+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1060
[W][01-10/15:23:17.008+9.0][4784,109315][local_channel_base.cc:141][local-trtc][39c0] Audio No frame sent for 5 seconds
[I][01-10/15:23:17.008+9.0][4784,109315][local_channel_manager.cc:921][local-trtc][39c0] Will update media state from [Audio:Has] to [None], by local:0
[I][01-10/15:23:17.310+9.0][4784,109315][local_channel_manager.cc:935][local-trtc][39c0] Request update media state
[I][01-10/15:23:17.311+9.0][4784,109315][signal_task.cc:117][local-trtc][39c0] C2SRequest: {cmd:C2SSubscribeRequest, seq:1985909827}
[I][01-10/15:23:17.323+9.0][4784,109315][signal_manager.cc:1027][local-trtc][39c0] Signal: C2SResponse: C2SSubscribeResponse, Seq: 1985909827, Tinyid: 144115243948468019, ErrorCode: 0, ErrorHandleMethod: 0
[I][01-10/15:23:17.991+9.0][4784,107779][audio_device_ios.mm:1428]AudioUnit is abnormal. is_interrupted=0 is_background=0
[I][01-10/15:23:17.992+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[I][01-10/15:23:17.992+9.0][4784,107779][ear_monitoring.cc:160]Clear EarMonitoring buffer
[W][01-10/15:23:17.993+9.0][4784,109315][trtc_pipeline.cc:3697][39c0]trtc_api: OnAudioWarning [code:1204|msg:AudioDevice: may be a problem with the audio capture device. ]
[I][01-10/15:23:17.997+9.0][4784,107779][audio_device_ios.mm:733]StartAudioUnit need_record=1 expect_route=kSpeakerPhone need_voip=1
[W][01-10/15:23:18.005+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:18.005+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[W][01-10/15:23:18.107+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:18.107+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[I][01-10/15:23:18.209+9.0][4784,107779][audio_device_ios.mm:744]StartAudioUnit done. initialize audio unit failed with system error1701737535.
[I][01-10/15:23:18.210+9.0][4784,107779][audio_device_ios.mm:758]StartAudioUnit hardware input gain: 1.0
[I][01-10/15:23:18.210+9.0][4784,107779][scoped_duration_calculator.cc:23]StartAudioUnit cost 214ms
[W][01-10/15:23:18.216+9.0][4784,107779][audio_device_ios.mm:1453]AudioUnit is abnormal. restart audiounit failed. code=initialize audio unit failed with system error1701737535.
[I][01-10/15:23:18.216+9.0][4784,109315][trtc_pipeline.cc:3832][39c0]AudioDevice: restart capture device. system error:1701737535. initialize audio unit failed. category:AVAudioSessionCategoryPlayAndRecord, options:13, mode:AVAudioSessionModeVoiceChat, hardware sample rate:48000, IO duration: 0.0213333, playout volume[5] is too low, system in VOIP mode, play device:kSpeakerPhone
[I][01-10/15:23:18.216+9.0][4784,109315][pipeline_notification_receiver.cc:72]Receive notification, abnormal event id 10012 msg: AudioDevice: may be a problem with the audio capture device.
[I][01-10/15:23:18.554+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1040
[I][01-10/15:23:20.707+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1040
[I][01-10/15:23:22.869+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1040
[I][01-10/15:23:22.992+9.0][4784,107779][audio_device_ios.mm:1428]AudioUnit is abnormal. is_interrupted=0 is_background=0
[I][01-10/15:23:22.992+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[W][01-10/15:23:22.992+9.0][4784,109315][trtc_pipeline.cc:3697][39c0]trtc_api: OnAudioWarning [code:1204|msg:AudioDevice: may be a problem with the audio capture device. ]
[I][01-10/15:23:22.992+9.0][4784,107779][ear_monitoring.cc:160]Clear EarMonitoring buffer
[I][01-10/15:23:22.999+9.0][4784,107779][audio_device_ios.mm:733]StartAudioUnit need_record=1 expect_route=kSpeakerPhone need_voip=1
[W][01-10/15:23:23.009+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:23.009+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[W][01-10/15:23:23.110+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:23.110+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[I][01-10/15:23:23.213+9.0][4784,107779][audio_device_ios.mm:744]StartAudioUnit done. initialize audio unit failed with system error1701737535.
[I][01-10/15:23:23.214+9.0][4784,107779][audio_device_ios.mm:758]StartAudioUnit hardware input gain: 1.0
[I][01-10/15:23:23.215+9.0][4784,107779][scoped_duration_calculator.cc:23]StartAudioUnit cost 216ms
[W][01-10/15:23:23.222+9.0][4784,107779][audio_device_ios.mm:1453]AudioUnit is abnormal. restart audiounit failed. code=initialize audio unit failed with system error1701737535.
[I][01-10/15:23:23.222+9.0][4784,109315][trtc_pipeline.cc:3832][39c0]AudioDevice: restart capture device. system error:1701737535. initialize audio unit failed. category:AVAudioSessionCategoryPlayAndRecord, options:13, mode:AVAudioSessionModeVoiceChat, hardware sample rate:48000, IO duration: 0.0213333, playout volume[5] is too low, system in VOIP mode, play device:kSpeakerPhone
[I][01-10/15:23:23.223+9.0][4784,109315][pipeline_notification_receiver.cc:72]Receive notification, abnormal event id 10012 msg: AudioDevice: may be a problem with the audio capture device.
[I][01-10/15:23:25.048+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1060
[I][01-10/15:23:27.187+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1040
[I][01-10/15:23:27.992+9.0][4784,107779][audio_device_ios.mm:1428]AudioUnit is abnormal. is_interrupted=0 is_background=0
[I][01-10/15:23:27.992+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[I][01-10/15:23:27.992+9.0][4784,107779][ear_monitoring.cc:160]Clear EarMonitoring buffer
[W][01-10/15:23:27.992+9.0][4784,109315][trtc_pipeline.cc:3697][39c0]trtc_api: OnAudioWarning [code:1204|msg:AudioDevice: may be a problem with the audio capture device. ]
[I][01-10/15:23:28.000+9.0][4784,107779][audio_device_ios.mm:733]StartAudioUnit need_record=1 expect_route=kSpeakerPhone need_voip=1
[W][01-10/15:23:28.009+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:28.009+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[W][01-10/15:23:28.111+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:28.111+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[I][01-10/15:23:28.214+9.0][4784,107779][audio_device_ios.mm:744]StartAudioUnit done. initialize audio unit failed with system error1701737535.
[I][01-10/15:23:28.215+9.0][4784,107779][audio_device_ios.mm:758]StartAudioUnit hardware input gain: 1.0
[I][01-10/15:23:28.216+9.0][4784,107779][scoped_duration_calculator.cc:23]StartAudioUnit cost 217ms
[W][01-10/15:23:28.223+9.0][4784,107779][audio_device_ios.mm:1453]AudioUnit is abnormal. restart audiounit failed. code=initialize audio unit failed with system error1701737535.
[I][01-10/15:23:28.223+9.0][4784,109315][trtc_pipeline.cc:3832][39c0]AudioDevice: restart capture device. system error:1701737535. initialize audio unit failed. category:AVAudioSessionCategoryPlayAndRecord, options:13, mode:AVAudioSessionModeVoiceChat, hardware sample rate:48000, IO duration: 0.0213333, playout volume[5] is too low, system in VOIP mode, play device:kSpeakerPhone
[I][01-10/15:23:28.225+9.0][4784,109315][pipeline_notification_receiver.cc:72]Receive notification, abnormal event id 10012 msg: AudioDevice: may be a problem with the audio capture device.
[I][01-10/15:23:29.368+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1060
[I][01-10/15:23:31.525+9.0][4784,131587][packet_buffer.cc:342][[39c0]:[uid:68][type:Audio][tinyid:144115242427185940]] Buffer is full, drop 108 packets. max_cache: 1200 current cache: 1060
[I][01-10/15:23:32.992+9.0][4784,107779][audio_device_ios.mm:1428]AudioUnit is abnormal. is_interrupted=0 is_background=0
[I][01-10/15:23:32.992+9.0][4784,107779][audio_device_ios.mm:793]ResetAudioUnit done.
[I][01-10/15:23:32.992+9.0][4784,107779][ear_monitoring.cc:160]Clear EarMonitoring buffer
[W][01-10/15:23:32.992+9.0][4784,109315][trtc_pipeline.cc:3697][39c0]trtc_api: OnAudioWarning [code:1204|msg:AudioDevice: may be a problem with the audio capture device. ]
[I][01-10/15:23:32.999+9.0][4784,107779][audio_device_ios.mm:733]StartAudioUnit need_record=1 expect_route=kSpeakerPhone need_voip=1
[W][01-10/15:23:33.009+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:33.009+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[W][01-10/15:23:33.110+9.0][4784,107779][audio_unit_wrapper.mm:602]Failed to initialize the audiounit. code=1701737535
[W][01-10/15:23:33.111+9.0][4784,107779][audio_unit_wrapper.mm:604]try audio unit initialization again...
[I][01-10/15:23:33.213+9.0][4784,107779][audio_device_ios.mm:744]StartAudioUnit done. initialize audio unit failed with system error1701737535.
[I][01-10/15:23:33.215+9.0][4784,107779][audio_device_ios.mm:758]StartAudioUnit hardware input gain: 1.0
[I][01-10/15:23:33.215+9.0][4784,107779][scoped_duration_calculator.cc:23]StartAudioUnit cost 216ms

Dominant language
Dart
Stars
82
Forks
39
Avg merge
27m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Tencent-RTC/TRTC_Flutter

All issues in Tencent-RTC/TRTC_Flutter

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.