| Index: webrtc/modules/audio_coding/neteq/decision_logic_normal.cc
|
| diff --git a/webrtc/modules/audio_coding/neteq/decision_logic_normal.cc b/webrtc/modules/audio_coding/neteq/decision_logic_normal.cc
|
| index 0252d1cdfaf214d927b160a8d000de8f1cb7601b..37a75d7f5ad61714d9aa9c1a4708c7608f1cd983 100644
|
| --- a/webrtc/modules/audio_coding/neteq/decision_logic_normal.cc
|
| +++ b/webrtc/modules/audio_coding/neteq/decision_logic_normal.cc
|
| @@ -31,7 +31,8 @@ Operations DecisionLogicNormal::GetDecisionSpecialized(
|
| const RTPHeader* packet_header,
|
| Modes prev_mode,
|
| bool play_dtmf,
|
| - bool* reset_decoder) {
|
| + bool* reset_decoder,
|
| + size_t generated_noise_samples) {
|
| assert(playout_mode_ == kPlayoutOn || playout_mode_ == kPlayoutStreaming);
|
| // Guard for errors, to avoid getting stuck in error mode.
|
| if (prev_mode == kModeError) {
|
| @@ -52,7 +53,8 @@ Operations DecisionLogicNormal::GetDecisionSpecialized(
|
| }
|
|
|
| if (is_cng_packet) {
|
| - return CngOperation(prev_mode, target_timestamp, available_timestamp);
|
| + return CngOperation(prev_mode, target_timestamp, available_timestamp,
|
| + generated_noise_samples);
|
| }
|
|
|
| // Handle the case with no packet at all available (except maybe DTMF).
|
| @@ -76,7 +78,8 @@ Operations DecisionLogicNormal::GetDecisionSpecialized(
|
| available_timestamp, target_timestamp, five_seconds_samples)) {
|
| return FuturePacketAvailable(sync_buffer, expand, decoder_frame_length,
|
| prev_mode, target_timestamp,
|
| - available_timestamp, play_dtmf);
|
| + available_timestamp, play_dtmf,
|
| + generated_noise_samples);
|
| } else {
|
| // This implies that available_timestamp < target_timestamp, which can
|
| // happen when a new stream or codec is received. Signal for a reset.
|
| @@ -86,10 +89,11 @@ Operations DecisionLogicNormal::GetDecisionSpecialized(
|
|
|
| Operations DecisionLogicNormal::CngOperation(Modes prev_mode,
|
| uint32_t target_timestamp,
|
| - uint32_t available_timestamp) {
|
| + uint32_t available_timestamp,
|
| + size_t generated_noise_samples) {
|
| // Signed difference between target and available timestamp.
|
| int32_t timestamp_diff = static_cast<int32_t>(
|
| - static_cast<uint32_t>(generated_noise_samples_ + target_timestamp) -
|
| + static_cast<uint32_t>(generated_noise_samples + target_timestamp) -
|
| available_timestamp);
|
| int32_t optimal_level_samp = static_cast<int32_t>(
|
| (delay_manager_->TargetLevel() * packet_length_samples_) >> 8);
|
| @@ -97,9 +101,9 @@ Operations DecisionLogicNormal::CngOperation(Modes prev_mode,
|
|
|
| if (excess_waiting_time_samp > optimal_level_samp / 2) {
|
| // The waiting time for this packet will be longer than 1.5
|
| - // times the wanted buffer delay. Advance the clock to cut
|
| + // times the wanted buffer delay. Apply fast-forward to cut the
|
| // waiting time down to the optimal.
|
| - generated_noise_samples_ += excess_waiting_time_samp;
|
| + noise_fast_forward_ += excess_waiting_time_samp;
|
| timestamp_diff += excess_waiting_time_samp;
|
| }
|
|
|
| @@ -109,6 +113,7 @@ Operations DecisionLogicNormal::CngOperation(Modes prev_mode,
|
| return kRfc3389CngNoPacket;
|
| } else {
|
| // Otherwise, go for the CNG packet now.
|
| + noise_fast_forward_ = 0;
|
| return kRfc3389Cng;
|
| }
|
| }
|
| @@ -153,7 +158,8 @@ Operations DecisionLogicNormal::FuturePacketAvailable(
|
| Modes prev_mode,
|
| uint32_t target_timestamp,
|
| uint32_t available_timestamp,
|
| - bool play_dtmf) {
|
| + bool play_dtmf,
|
| + size_t generated_noise_samples) {
|
| // Required packet is not available, but a future packet is.
|
| // Check if we should continue with an ongoing expand because the new packet
|
| // is too far into the future.
|
| @@ -184,7 +190,7 @@ Operations DecisionLogicNormal::FuturePacketAvailable(
|
| // safety precaution), but make sure that the number of samples in buffer
|
| // is no higher than 4 times the optimal level. (Note that TargetLevel()
|
| // is in Q8.)
|
| - if (static_cast<uint32_t>(generated_noise_samples_ + target_timestamp) >=
|
| + if (static_cast<uint32_t>(generated_noise_samples + target_timestamp) >=
|
| available_timestamp ||
|
| cur_size_samples >
|
| ((delay_manager_->TargetLevel() * packet_length_samples_) >> 8) *
|
|
|