Allowing resetting of AudioNetworkAdaptor in AudioSendStream.

BUG=webrtc:6681

Review-Url: https://codereview.webrtc.org/2495833002
Cr-Commit-Position: refs/heads/master@{#15058}
diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc
index fef5b1d..70bb6a9 100644
--- a/webrtc/audio/audio_send_stream.cc
+++ b/webrtc/audio/audio_send_stream.cc
@@ -292,6 +292,12 @@
   codec->SetVADStatus(channel, false);
   codec->SetFECStatus(channel, false);
 
+  // We disable audio network adaptor here. This will on one hand make sure that
+  // audio network adaptor is disabled by default, and on the other allow audio
+  // network adaptor to be reconfigured, since SetReceiverFrameLengthRange can
+  // be only called when audio network adaptor is disabled.
+  channel_proxy_->DisableAudioNetworkAdaptor();
+
   const auto& send_codec_spec = config_.send_codec_spec;
 
   // We set the codec first, since the below extra configuration is only applied
@@ -345,8 +351,6 @@
           *config_.audio_network_adaptor_config);
       LOG(LS_INFO) << "Audio network adaptor enabled on SSRC "
                    << config_.rtp.ssrc;
-    } else {
-      channel_proxy_->DisableAudioNetworkAdaptor();
     }
   }
 
diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc
index bd7ffb7..fc7bbb0 100644
--- a/webrtc/audio/audio_send_stream_unittest.cc
+++ b/webrtc/audio/audio_send_stream_unittest.cc
@@ -142,6 +142,7 @@
         .WillOnce(Return(0));
     EXPECT_CALL(voice_engine_, SetFECStatus(kChannelId, false))
         .WillOnce(Return(0));
+    EXPECT_CALL(*channel_proxy_, DisableAudioNetworkAdaptor());
     // Let |GetSendCodec| return -1 for the first time to indicate that no send
     // codec has been set.
     EXPECT_CALL(voice_engine_, GetSendCodec(kChannelId, _))