summaryrefslogtreecommitdiffstats
path: root/media/cast/audio_receiver/audio_receiver.cc
diff options
context:
space:
mode:
authormikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 02:19:09 +0000
committermikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 02:19:09 +0000
commit2d6036cd515f907e2fd41f48c96115108c4448e2 (patch)
tree13296036eed708cbe69f85c86c6e8f9872ace5d1 /media/cast/audio_receiver/audio_receiver.cc
parent9744a3bbff89194b2fe04d563fd6c03bdfd58b08 (diff)
downloadchromium_src-2d6036cd515f907e2fd41f48c96115108c4448e2.zip
chromium_src-2d6036cd515f907e2fd41f48c96115108c4448e2.tar.gz
chromium_src-2d6036cd515f907e2fd41f48c96115108c4448e2.tar.bz2
Cast: Don't let time go backwards
This cl eliminates the possibility that the video render time or the audio playout time will go back in time. Every frame's render/playout time will be either greater or equal to it's prior frame. BUG= 327474 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=240142 Review URL: https://codereview.chromium.org/106663009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/audio_receiver/audio_receiver.cc')
-rw-r--r--media/cast/audio_receiver/audio_receiver.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/media/cast/audio_receiver/audio_receiver.cc b/media/cast/audio_receiver/audio_receiver.cc
index f7c3350..a6db555 100644
--- a/media/cast/audio_receiver/audio_receiver.cc
+++ b/media/cast/audio_receiver/audio_receiver.cc
@@ -389,6 +389,7 @@ base::TimeTicks AudioReceiver::GetPlayoutTime(base::TimeTicks now,
// Senders time in ms when this frame was recorded.
// Note: the senders clock and our local clock might not be synced.
base::TimeTicks rtp_timestamp_in_ticks;
+ base::TimeTicks playout_time;
if (time_offset_ == base::TimeDelta()) {
if (rtcp_->RtpTimestampInSenderTime(frequency_,
first_incoming_rtp_timestamp_,
@@ -404,15 +405,21 @@ base::TimeTicks AudioReceiver::GetPlayoutTime(base::TimeTicks now,
base::TimeDelta::FromMilliseconds(rtp_timestamp_diff / frequency_khz);
base::TimeDelta time_diff_delta = now - time_first_incoming_packet_;
- return now + std::max(rtp_time_diff_delta - time_diff_delta,
- base::TimeDelta());
+ playout_time = now + std::max(rtp_time_diff_delta - time_diff_delta,
+ base::TimeDelta());
}
}
- // This can fail if we have not received any RTCP packets in a long time.
- return rtcp_->RtpTimestampInSenderTime(frequency_, rtp_timestamp,
- &rtp_timestamp_in_ticks) ?
- rtp_timestamp_in_ticks + time_offset_ + target_delay_delta_ :
- now;
+ if (playout_time.is_null()) {
+ // This can fail if we have not received any RTCP packets in a long time.
+ playout_time = rtcp_->RtpTimestampInSenderTime(frequency_, rtp_timestamp,
+ &rtp_timestamp_in_ticks) ?
+ rtp_timestamp_in_ticks + time_offset_ + target_delay_delta_ : now;
+ }
+ // Don't allow the playout time to go backwards.
+ if (last_playout_time_ > playout_time)
+ playout_time = last_playout_time_;
+ last_playout_time_ = playout_time;
+ return playout_time;
}
bool AudioReceiver::DecryptAudioFrame(