Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions webrtc-sys/libwebrtc/patches/external_audio_source.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ index 643b5f273b..7b5b568692 100644

// Interface of the audio processor used by the audio track to collect
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index e9e72b48e7..ca21052ff7 100644
index e9e72b48e7..76c310ee67 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -377,8 +377,13 @@ void AudioSendStream::Start() {
Expand All @@ -34,11 +34,10 @@ index e9e72b48e7..ca21052ff7 100644
}

void AudioSendStream::Stop() {
@@ -389,8 +394,10 @@ void AudioSendStream::Stop() {
RTC_LOG(LS_INFO) << "AudioSendStream::Stop: " << config_.rtp.ssrc;
@@ -390,7 +395,10 @@ void AudioSendStream::Stop() {
RemoveBitrateObserver();
channel_send_->StopSend();
- sending_ = false;
sending_ = false;
- audio_state()->RemoveSendingStream(this);
+ // Only unregister if we registered (when not using external source).
+ if (!config_.external_source) {
Expand All @@ -47,6 +46,17 @@ index e9e72b48e7..ca21052ff7 100644
}

void AudioSendStream::SendAudioData(std::unique_ptr<AudioFrame> audio_frame) {
@@ -581,7 +589,9 @@ void AudioSendStream::StoreEncoderProperties(int sample_rate_hz,
size_t num_channels) {
encoder_sample_rate_hz_ = sample_rate_hz;
encoder_num_channels_ = num_channels;
- if (sending_) {
+ // External sources never registered with AudioState (see Start()), and
+ // must not be added here either: Stop() would not remove them again.
+ if (sending_ && !config_.external_source) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Existing WebRTC artifact retains audio crash

For default builds, StoreEncoderProperties() still runs from the unchanged prebuilt WebRTC artifact. WEBRTC_TAG selects that artifact, so publishing and removing native audio tracks during platform capture can still crash.

Learn more

The default build links a downloaded WebRTC static library rather than compiling this patch. WEBRTC_TAG still names the existing release, and download_url selects its unchanged archive. The new condition exists only in a WebRTC build made from the updated patch. Until a patched archive is published and selected, default SDK builds retain the dangling send-stream behavior under active platform capture.

Example: An application installs this SDK update without setting LK_CUSTOM_WEBRTC. It downloads the existing webrtc-89d790b archive, then repeatedly publishes and removes a stereo NativeAudioSource track while PlatformAudio records. The archive still registers the external stream in AudioState, so the capture thread can reach it after destruction.

Recommended fix: Build and publish patched WebRTC artifacts for supported targets, update WEBRTC_TAG to the new artifact release, and verify a default SDK build uses them.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

// Update AudioState's information about the stream.
audio_state()->AddSendingStream(this, sample_rate_hz, num_channels);
}
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index 40bfd812a4..a482b16d70 100644
--- a/call/audio_send_stream.h
Expand Down
Loading