Add mute state field to AudioFrame and switch some callers to use it. Also make AudioFrame::data_ private and instead provide:

const int16_t* data() const;
int16_t* mutable_data();

- data() returns a zeroed static buffer on muted frames (to avoid unnecessary zeroing of the member buffer) and directly returns AudioFrame::data_ on unmuted frames.
- mutable_data(), lazily zeroes AudioFrame::data_ if the frame is currently muted, sets muted=false, and returns AudioFrame::data_.

These accessors serve to "force" callers to be aware of the mute state field, i.e. lazy zeroing is not the primary motivation.

This change only optimizes handling of muted frames where it is somewhat trivial to do so. Other improvements requiring more significant structural changes will come later.

BUG=webrtc:7343
TBR=henrika

Review-Url: https://codereview.webrtc.org/2750783004
Cr-Commit-Position: refs/heads/master@{#18543}
This commit is contained in:
yujo
2017-06-12 12:45:32 -07:00
committed by Commit Bot
parent 0703856b53
commit 36b1a5fcec
55 changed files with 658 additions and 316 deletions

View File

@ -216,7 +216,7 @@ class NetEqImplTest : public ::testing::Test {
1512, 2378, 2828, 2674, 1877, 568, -986, -2446, -3482, -3864, -3516,
-2534, -1163 });
ASSERT_GE(kMaxOutputSize, kOutput.size());
EXPECT_TRUE(std::equal(kOutput.begin(), kOutput.end(), output.data_));
EXPECT_TRUE(std::equal(kOutput.begin(), kOutput.end(), output.data()));
}
std::unique_ptr<NetEqImpl> neteq_;
@ -525,7 +525,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
// Wrap the expected value in an rtc::Optional to compare them as such.
EXPECT_EQ(
rtc::Optional<uint32_t>(rtp_header.timestamp +
output.data_[output.samples_per_channel_ - 1]),
output.data()[output.samples_per_channel_ - 1]),
neteq_->GetPlayoutTimestamp());
// Check the timestamp for the last value in the sync buffer. This should
@ -538,7 +538,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
// Check that the number of samples still to play from the sync buffer add
// up with what was already played out.
EXPECT_EQ(
kPayloadLengthSamples - output.data_[output.samples_per_channel_ - 1],
kPayloadLengthSamples - output.data()[output.samples_per_channel_ - 1],
sync_buffer->FutureLength());
}