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 <toprice@chromium.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35401}
This commit is contained in:
Tony Herre 2021-11-22 19:10:19 +01:00 committed by WebRTC LUCI CQ
parent a9730e5292
commit f05f2823b3

View File

@ -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.