Commit 0d5c8a26 authored by Aidan Wolter's avatar Aidan Wolter Committed by Commit Bot

Return delay of 0 for invalid timestamps

Invalid timestamps can occur when a stream is closed. These timestamps
are represented by the minimum value of an int64. This change catches
this value and stops interpretting it as a valid timestamp. The
rendering pipeline was crashing when receiving negative timestamps.

Bug: b/115771591
Test: Play YT, Hit next/prev
Change-Id: I0809a9563aa1e865e4832cbecb6a54886a350f2f
Reviewed-on: https://chromium-review.googlesource.com/1235291Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Commit-Queue: Aidan Wolter <awolter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592685}
parent 69ec4972
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
} while (0) } while (0)
namespace { namespace {
const int64_t kInvalidTimestamp = std::numeric_limits<int64_t>::min();
const int kMaxQueuedDataMs = 1000; const int kMaxQueuedDataMs = 1000;
} // namespace } // namespace
...@@ -250,6 +251,14 @@ void CastAudioOutputStream::CmaWrapper::PushBuffer() { ...@@ -250,6 +251,14 @@ void CastAudioOutputStream::CmaWrapper::PushBuffer() {
base::TimeTicks delay_timestamp = base::TimeTicks delay_timestamp =
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMicroseconds(rendering_delay.timestamp_microseconds); base::TimeDelta::FromMicroseconds(rendering_delay.timestamp_microseconds);
// The delay must be greater than zero, and if the timestamp is invalid, we
// cannot trust the current delay.
if (rendering_delay.timestamp_microseconds == kInvalidTimestamp ||
rendering_delay.delay_microseconds < 0) {
delay = base::TimeDelta();
}
int frame_count = int frame_count =
source_callback_->OnMoreData(delay, delay_timestamp, 0, audio_bus_.get()); source_callback_->OnMoreData(delay, delay_timestamp, 0, audio_bus_.get());
VLOG(3) << "frames_filled=" << frame_count << " with latency=" << delay; VLOG(3) << "frames_filled=" << frame_count << " with latency=" << delay;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment