Issue Description
System audio playback functions as expected during initial screen sharing. Subsequent updates to screen sharing parameters result in the cessation of local audio playback despite the absence of explicit changes to audio routing.
Platform/SDK
Operating System: macOS
SDK: Agora RTC SDK for macOS versions earlier than 4.5.3
Root Cause
The cessation of audio is caused by the implicit evaluation of the capture configuration during a parameter update. When the method RtcEngine::updateScreenCaptureParameters is invoked, the media engine processes the provided configuration object in its entirety.
If the captureAudio field within the captureParams structure is not explicitly set to true during this call, the SDK defaults to a disabled state for the audio capture path. This resulting state change leads to the loss of system audio transmission despite the fact that only video-related parameters were intended for modification.
Step-by-Step Solution
-
Enforce Explicit Audio Capture Definitions
Incorporate the
captureAudiofield in every invocation of the update method. Developers must ensure thatcaptureParams.captureAudiois consistently set totruewithin the application logic to maintain the audio stream whenever screen sharing parameters are refreshed.captureParams.captureAudio = true;
-
Adopt Unified Sharing Interfaces
For macOS applications that require the simultaneous delivery of screen content and system audio, utilize the
RtcEngine::startScreenCaptureAPI. This interface is specifically designed to handle concurrent media tracks and provides superior stability compared to the older loopback recording methods.- avoid using
enableLoopbackRecording
- avoid using
-
Transition to Stabilized SDK Versions
Upgrade the project to Agora SDK version 4.5.3 or later. These versions include optimizations to the parameter handling logic that prevent the unintended deactivation of the audio path during partial updates.
-
Reinitialize Active Sessions
If the audio path is already compromised due to a parameter mismatch, the application should restart the screen sharing session. This action refreshes the media pipeline and applies the correct capture settings from the initialization phase.
Best Practice
To ensure a consistent user experience, developers should treat screen sharing parameters as a complete state rather than incremental changes. By explicitly defining the audio capture requirements in every update call, the risk of accidental media loss is eliminated.
Corresponding Document/Link
Agora Documentation: Screen Sharing on macOS
API Reference: updateScreenCaptureParameters