Index: webrtc/voice_engine/channel.cc |
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc |
index 1d73db6d396a29ab1bc3ca12beee0c8ce1106ae0..0f0831c8b1f8cbd737a7b919e4a277b04cb87ff1 100644 |
--- a/webrtc/voice_engine/channel.cc |
+++ b/webrtc/voice_engine/channel.cc |
@@ -21,7 +21,6 @@ |
#include "webrtc/base/location.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/rate_limiter.h" |
-#include "webrtc/base/thread_checker.h" |
#include "webrtc/base/timeutils.h" |
#include "webrtc/config.h" |
#include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
@@ -935,50 +934,12 @@ Channel::Channel(int32_t channelId, |
} |
Channel::~Channel() { |
- rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); |
- WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
- "Channel::~Channel() - dtor"); |
- |
- StopSend(); |
- StopPlayout(); |
- |
- { |
- rtc::CritScope cs(&_fileCritSect); |
- if (input_file_player_) { |
- input_file_player_->RegisterModuleFileCallback(NULL); |
- input_file_player_->StopPlayingFile(); |
- } |
- if (output_file_player_) { |
- output_file_player_->RegisterModuleFileCallback(NULL); |
- output_file_player_->StopPlayingFile(); |
- } |
- if (output_file_recorder_) { |
- output_file_recorder_->RegisterModuleFileCallback(NULL); |
- output_file_recorder_->StopRecording(); |
- } |
- } |
- |
- // The order to safely shutdown modules in a channel is: |
- // 1. De-register callbacks in modules |
- // 2. De-register modules in process thread |
- // 3. Destroy modules |
- if (audio_coding_->RegisterTransportCallback(NULL) == -1) { |
- WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
- "~Channel() failed to de-register transport callback" |
- " (Audio coding module)"); |
- } |
- if (audio_coding_->RegisterVADCallback(NULL) == -1) { |
- WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
- "~Channel() failed to de-register VAD callback" |
- " (Audio coding module)"); |
- } |
- // De-register modules in process thread |
- _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
- |
- // End of modules shutdown |
+ RTC_DCHECK(!channel_state_.Get().sending); |
+ RTC_DCHECK(!channel_state_.Get().playing); |
} |
int32_t Channel::Init() { |
+ RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
"Channel::Init()"); |
@@ -1081,6 +1042,56 @@ int32_t Channel::Init() { |
return 0; |
} |
+void Channel::Terminate() { |
+ RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
+ // Must be called on the same thread as Init(). |
+ WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
+ "Channel::Terminate"); |
+ |
+ rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); |
+ |
+ StopSend(); |
the sun
2017/03/20 19:11:12
StopSend() looks like it has races. I'm thinking o
tommi
2017/03/21 09:07:45
I can look into whether we can put thread checks t
|
+ StopPlayout(); |
+ |
+ { |
+ rtc::CritScope cs(&_fileCritSect); |
+ if (input_file_player_) { |
+ input_file_player_->RegisterModuleFileCallback(NULL); |
+ input_file_player_->StopPlayingFile(); |
+ } |
+ if (output_file_player_) { |
+ output_file_player_->RegisterModuleFileCallback(NULL); |
+ output_file_player_->StopPlayingFile(); |
+ } |
+ if (output_file_recorder_) { |
+ output_file_recorder_->RegisterModuleFileCallback(NULL); |
+ output_file_recorder_->StopRecording(); |
+ } |
+ } |
+ |
+ // The order to safely shutdown modules in a channel is: |
+ // 1. De-register callbacks in modules |
+ // 2. De-register modules in process thread |
+ // 3. Destroy modules |
+ if (audio_coding_->RegisterTransportCallback(NULL) == -1) { |
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
+ "Terminate() failed to de-register transport callback" |
+ " (Audio coding module)"); |
+ } |
+ |
+ if (audio_coding_->RegisterVADCallback(NULL) == -1) { |
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
+ "Terminate() failed to de-register VAD callback" |
+ " (Audio coding module)"); |
+ } |
+ |
+ // De-register modules in process thread |
+ if (_moduleProcessThreadPtr) |
+ _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
+ |
+ // End of modules shutdown |
+} |
+ |
int32_t Channel::SetEngineInformation(Statistics& engineStatistics, |
OutputMixer& outputMixer, |
ProcessThread& moduleProcessThread, |