Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: chromecast/media/cma/backend/multizone_backend_unittest.cc

Issue 2133293003: [Chromecast] Make ALSA rendering delay either accurate or kNoTimestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix ALSA unit tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/media/cma/backend/multizone_backend_unittest.cc
diff --git a/chromecast/media/cma/backend/multizone_backend_unittest.cc b/chromecast/media/cma/backend/multizone_backend_unittest.cc
index c7400bf80786eacb45946998aa275091ee16c19c..503f802f42ab1fddd44bf44bb8ceba499f75cedf 100644
--- a/chromecast/media/cma/backend/multizone_backend_unittest.cc
+++ b/chromecast/media/cma/backend/multizone_backend_unittest.cc
@@ -41,9 +41,9 @@ const int64_t kMicrosecondsPerSecond = 1000 * 1000;
// Total length of test, in microseconds.
const int64_t kPushTimeUs = 2 * kMicrosecondsPerSecond;
const int64_t kStartPts = 0;
-const int64_t kRenderingDelayGracePeriodUs = 250 * 1000;
const int64_t kMaxRenderingDelayErrorUs = 200;
const int kNumEffectsStreams = 1;
+const int64_t kNoTimestamp = std::numeric_limits<int64_t>::min();
void IgnoreEos() {}
@@ -171,7 +171,7 @@ BufferFeeder::BufferFeeder(const AudioConfig& config,
push_limit_us_(effects_only_ ? 0 : kPushTimeUs),
last_push_length_us_(0),
pushed_us_(0),
- next_push_playback_timestamp_(0) {
+ next_push_playback_timestamp_(kNoTimestamp) {
CHECK(!eos_cb_.is_null());
}
@@ -246,26 +246,30 @@ void BufferFeeder::OnPushBufferComplete(BufferStatus status) {
if (!effects_only_) {
MediaPipelineBackend::AudioDecoder::RenderingDelay delay =
decoder_->GetRenderingDelay();
- int64_t expected_next_push_playback_timestamp =
- next_push_playback_timestamp_ + last_push_length_us_;
- next_push_playback_timestamp_ =
- delay.timestamp_microseconds + delay.delay_microseconds;
- // Check rendering delay accuracy only if we have pushed more than
- // kRenderingDelayGracePeriodUs of data.
- if (pushed_us_ > kRenderingDelayGracePeriodUs) {
- int64_t error =
- next_push_playback_timestamp_ - expected_next_push_playback_timestamp;
- max_rendering_delay_error_us_ =
- std::max(max_rendering_delay_error_us_, std::abs(error));
- total_rendering_delay_error_us_ += std::abs(error);
- if (error >= 0) {
- max_positive_rendering_delay_error_us_ =
- std::max(max_positive_rendering_delay_error_us_, error);
+
+ if (delay.timestamp_microseconds != kNoTimestamp) {
+ if (next_push_playback_timestamp_ == kNoTimestamp) {
+ next_push_playback_timestamp_ =
+ delay.timestamp_microseconds + delay.delay_microseconds;
} else {
- max_negative_rendering_delay_error_us_ =
- std::min(max_negative_rendering_delay_error_us_, error);
+ int64_t expected_next_push_playback_timestamp =
+ next_push_playback_timestamp_ + last_push_length_us_;
+ next_push_playback_timestamp_ =
+ delay.timestamp_microseconds + delay.delay_microseconds;
+ int64_t error = next_push_playback_timestamp_ -
+ expected_next_push_playback_timestamp;
+ max_rendering_delay_error_us_ =
+ std::max(max_rendering_delay_error_us_, std::abs(error));
+ total_rendering_delay_error_us_ += std::abs(error);
+ if (error >= 0) {
+ max_positive_rendering_delay_error_us_ =
+ std::max(max_positive_rendering_delay_error_us_, error);
+ } else {
+ max_negative_rendering_delay_error_us_ =
+ std::min(max_negative_rendering_delay_error_us_, error);
+ }
+ sample_count_++;
}
- sample_count_++;
}
}
pushed_us_ += last_push_length_us_;
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698