From 5b7120c81b2506f1bd91d5562cf39a6d970b6a1e Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Mon, 29 Apr 2013 16:41:30 +0000 Subject: [PATCH] Fix two issues where we might end up busy looping in decoder_render mode. This happens if - Next frame is far into the future (> 200 ms). - Next frame is ready for decode/render but incomplete. BUG=1696 TESTS=trybots Review URL: https://webrtc-codereview.appspot.com/1354005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3914 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/video_coding/main/source/receiver.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/webrtc/modules/video_coding/main/source/receiver.cc b/webrtc/modules/video_coding/main/source/receiver.cc index 65d7a6839f..ae0f1cec92 100644 --- a/webrtc/modules/video_coding/main/source/receiver.cc +++ b/webrtc/modules/video_coding/main/source/receiver.cc @@ -296,15 +296,21 @@ VCMEncodedFrame* VCMReceiver::FrameForRendering(uint16_t max_wait_time_ms, uint32_t wait_time_ms = timing_->MaxWaitingTime( next_render_time_ms, clock_->TimeInMilliseconds()); if (max_wait_time_ms < wait_time_ms) { - // If we're not allowed to wait until the frame is supposed to be rendered - // we will have to return NULL for now. + // If we're not allowed to wait until the frame is supposed to be rendered, + // waiting as long as we're allowed to avoid busy looping, and then return + // NULL. Next call to this function might return the frame. + render_wait_event_->Wait(max_wait_time_ms); return NULL; } // Wait until it's time to render. render_wait_event_->Wait(wait_time_ms); // Get a complete frame if possible. - VCMEncodedFrame* frame = jitter_buffer_.GetCompleteFrameForDecoding(0); + // Note: This might cause us to wait more than a total of |max_wait_time_ms|. + // This is necessary to avoid a possible busy loop if no complete frame + // has been received. + VCMEncodedFrame* frame = jitter_buffer_.GetCompleteFrameForDecoding( + max_wait_time_ms); if (frame == NULL) { // Get an incomplete frame.