Add AudioReceiveStream::SetGain() method and use that in WVoMC::SetOutputVolume().
Removes the need to use VoEVolume::SetChannelOutputVolumeScaling().
BUG=webrtc:4690
Review-Url: https://codereview.webrtc.org/2062193002
Cr-Commit-Position: refs/heads/master@{#13194}
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc
index eb9b4bb..2ddf67d 100644
--- a/webrtc/media/engine/webrtcvoiceengine.cc
+++ b/webrtc/media/engine/webrtcvoiceengine.cc
@@ -1341,6 +1341,11 @@
stream_->SetSink(std::move(sink));
}
+ void SetOutputVolume(double volume) {
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
+ stream_->SetGain(volume);
+ }
+
private:
void RecreateAudioReceiveStream(
uint32_t local_ssrc,
@@ -2270,19 +2275,14 @@
}
ssrc = static_cast<uint32_t>(default_recv_ssrc_);
}
- int ch_id = GetReceiveChannelId(ssrc);
- if (ch_id < 0) {
- LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc;
+ const auto it = recv_streams_.find(ssrc);
+ if (it == recv_streams_.end()) {
+ LOG(LS_WARNING) << "SetOutputVolume: no recv stream" << ssrc;
return false;
}
-
- if (-1 == engine()->voe()->volume()->SetChannelOutputVolumeScaling(ch_id,
- volume)) {
- LOG_RTCERR2(SetChannelOutputVolumeScaling, ch_id, volume);
- return false;
- }
- LOG(LS_INFO) << "SetOutputVolume to " << volume
- << " for channel " << ch_id << " and ssrc " << ssrc;
+ it->second->SetOutputVolume(volume);
+ LOG(LS_INFO) << "SetOutputVolume() to " << volume
+ << " for recv stream with ssrc " << ssrc;
return true;
}