Chromium Code Reviews| Index: webrtc/voice_engine/channel.cc |
| diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc |
| index 8c9b00179f37c705a4356475d3baaa9aef52da7b..0a5ecb96c3fda5af2b6fdc5b49f1ba2274dcbfbf 100644 |
| --- a/webrtc/voice_engine/channel.cc |
| +++ b/webrtc/voice_engine/channel.cc |
| @@ -2711,7 +2711,13 @@ int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { |
| } |
| void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) { |
| - RTC_DCHECK(channel_state_.Get().sending); |
| + // TODO(nisse): This is not quite enough to avoid race on |
| + // destruction. In case we are preempted after this check, and some |
| + // other thread calls ChannelManager::DestroyChannel whch calls |
|
henrika_webrtc
2017/04/26 14:16:01
nit, which
Also, in your failing test, why did yo
|
| + // StopSend, StopSend's flush task gets posted *before* we post our |
| + // task, our task can get run at the same time as the destructor. |
|
the sun
2017/04/26 20:29:03
Can we use ChannelOwner to allow the task to keep
|
| + if (!channel_state_.Get().sending) |
| + return; |
| std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); |
| // TODO(henrika): try to avoid copying by moving ownership of audio frame |
| // either into pool of frames or into the task itself. |
| @@ -2725,7 +2731,8 @@ void Channel::ProcessAndEncodeAudio(const int16_t* audio_data, |
| int sample_rate, |
| size_t number_of_frames, |
| size_t number_of_channels) { |
| - RTC_DCHECK(channel_state_.Get().sending); |
| + if (!channel_state_.Get().sending) |
| + return; |
| CodecInst codec; |
| GetSendCodec(codec); |
| std::unique_ptr<AudioFrame> audio_frame(new AudioFrame()); |