From f05f2823b3a5ee96fc194d9a44f7a0f518a70cef Mon Sep 17 00:00:00 2001 From: Tony Herre Date: Mon, 22 Nov 2021 19:10:19 +0100 Subject: [PATCH] Allow setting volume on unstarted AudioRtpReceivers This was the behaviour before https://webrtc-review.googlesource.com/c/src/+/218605, and is currently relied upon by Chrome to mute received audio tracks by default, until they should be played out. Bug: chromium:1272566 Change-Id: I8a288a287e7c01392f4af1db5b083e8d7ee7b2a8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238665 Commit-Queue: Tony Herre Reviewed-by: Tommi Cr-Commit-Position: refs/heads/main@{#35401} --- pc/audio_rtp_receiver.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index 4efab24d15..cfaee40480 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -93,11 +93,14 @@ void AudioRtpReceiver::OnSetVolume(double volume) { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RTC_DCHECK_GE(volume, 0); RTC_DCHECK_LE(volume, 10); + + // Update the cached_volume_ even when stopped_, to allow clients to set the + // volume before starting/restarting, eg see crbug.com/1272566. + cached_volume_ = volume; + if (stopped_) return; - cached_volume_ = volume; - // When the track is disabled, the volume of the source, which is the // corresponding WebRtc Voice Engine channel will be 0. So we do not allow // setting the volume to the source when the track is disabled.