From 673027b4a5911adbf4f98fb46b28d73000c30fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Fri, 11 Sep 2020 09:19:30 +0200 Subject: [PATCH] Make NetEqController::TargetLevelMs const, part 2 Followup to https://webrtc-review.googlesource.com/c/src/+/183881. Bug: webrtc:11622 Change-Id: I8d76bf082e81ba1217d20e57c6ae6555eca2fc7b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183883 Reviewed-by: Ivo Creusen Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#32078} --- api/neteq/neteq_controller.h | 10 +--------- modules/audio_coding/neteq/decision_logic.h | 2 +- .../audio_coding/neteq/mock/mock_neteq_controller.h | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/api/neteq/neteq_controller.h b/api/neteq/neteq_controller.h index 9cad41515c..3c52b39b6f 100644 --- a/api/neteq/neteq_controller.h +++ b/api/neteq/neteq_controller.h @@ -152,15 +152,7 @@ class NetEqController { virtual void AddSampleMemory(int32_t value) = 0; // Returns the target buffer level in ms. - // TODO(bugs.webrtc.org/11622): Delete the non-const version and default - // implementation, once downstream code is updated. - virtual int TargetLevelMs() { - return const_cast(this)->TargetLevelMs(); - } - - virtual int TargetLevelMs() const { - return const_cast(this)->TargetLevelMs(); - } + virtual int TargetLevelMs() const = 0; // Notify the NetEqController that a packet has arrived. Returns the relative // arrival delay, if it can be computed. diff --git a/modules/audio_coding/neteq/decision_logic.h b/modules/audio_coding/neteq/decision_logic.h index 5f1a414019..23af0c5948 100644 --- a/modules/audio_coding/neteq/decision_logic.h +++ b/modules/audio_coding/neteq/decision_logic.h @@ -70,7 +70,7 @@ class DecisionLogic : public NetEqController { // Adds |value| to |sample_memory_|. void AddSampleMemory(int32_t value) override { sample_memory_ += value; } - int TargetLevelMs() override { + int TargetLevelMs() const override { return ((delay_manager_->TargetLevel() * packet_length_samples_) >> 8) / rtc::CheckedDivExact(sample_rate_, 1000); } diff --git a/modules/audio_coding/neteq/mock/mock_neteq_controller.h b/modules/audio_coding/neteq/mock/mock_neteq_controller.h index b7df85fb20..ec348caed0 100644 --- a/modules/audio_coding/neteq/mock/mock_neteq_controller.h +++ b/modules/audio_coding/neteq/mock/mock_neteq_controller.h @@ -41,7 +41,7 @@ class MockNetEqController : public NetEqController { MOCK_METHOD(void, SetCngOff, (), (override)); MOCK_METHOD(void, ExpandDecision, (NetEq::Operation operation), (override)); MOCK_METHOD(void, AddSampleMemory, (int32_t value), (override)); - MOCK_METHOD(int, TargetLevelMs, (), (override)); + MOCK_METHOD(int, TargetLevelMs, (), (const, override)); MOCK_METHOD(absl::optional, PacketArrived, (bool last_cng_or_dtmf,