Revert "Avoid acquiring VCM::_receiveCritSect during decode callback."

This reverts commit aa3528a9cd65b176b9d6f9d58cecb1068891dca4.

BUG=http://crbug.com/170345
TEST=libjingle_peerconnection_unittest
TBR=stefan,wu

Review URL: https://webrtc-codereview.appspot.com/1999004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4510 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wuchengli@chromium.org 2013-08-09 04:42:51 +00:00
parent a717ee9962
commit f4081ab8d8
2 changed files with 17 additions and 21 deletions

View File

@ -1665,10 +1665,6 @@ CallStatsObserver* ViEChannel::GetStatsObserver() {
return stats_observer_.get();
}
// Do not acquire the lock of |vcm_| in this function. Decode callback won't
// necessarily be called from the decoding thread. The decoding thread may have
// held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring
// the same lock in the path of decode callback can deadlock.
int32_t ViEChannel::FrameToRender(
I420VideoFrame& video_frame) { // NOLINT
CriticalSectionScoped cs(callback_cs_.get());
@ -1676,11 +1672,20 @@ int32_t ViEChannel::FrameToRender(
if (decoder_reset_) {
// Trigger a callback to the user if the incoming codec has changed.
if (codec_observer_) {
// VCM::ReceiveCodec returns the codec set by RegisterReceiveCodec, which
// might not be the size we're actually decoding.
receive_codec_.width = static_cast<uint16_t>(video_frame.width());
receive_codec_.height = static_cast<uint16_t>(video_frame.height());
codec_observer_->IncomingCodecChanged(channel_id_, receive_codec_);
VideoCodec decoder;
memset(&decoder, 0, sizeof(decoder));
if (vcm_.ReceiveCodec(&decoder) == VCM_OK) {
// VCM::ReceiveCodec returns the codec set by
// RegisterReceiveCodec, which might not be the size we're
// actually decoding.
decoder.width = static_cast<uint16_t>(video_frame.width());
decoder.height = static_cast<uint16_t>(video_frame.height());
codec_observer_->IncomingCodecChanged(channel_id_, decoder);
} else {
assert(false);
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
"%s: Could not get receive codec", __FUNCTION__);
}
}
decoder_reset_ = false;
}
@ -1944,17 +1949,9 @@ int32_t ViEChannel::OnInitializeDecoder(
payload_type, payload_name);
vcm_.ResetDecoder();
VideoCodec receive_codec;
memset(&receive_codec, 0, sizeof(receive_codec));
if (vcm_.ReceiveCodec(&receive_codec) == VCM_OK) {
CriticalSectionScoped cs(callback_cs_.get());
decoder_reset_ = true;
receive_codec_ = receive_codec;
} else {
assert(false);
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
"%s: Could not get receive codec", __FUNCTION__);
}
callback_cs_->Enter();
decoder_reset_ = true;
callback_cs_->Leave();
return 0;
}

View File

@ -383,7 +383,6 @@ class ViEChannel
Transport* external_transport_;
bool decoder_reset_;
VideoCodec receive_codec_;
bool wait_for_key_frame_;
ThreadWrapper* decode_thread_;