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

Side by Side Diff: chromecast/media/cma/backend/alsa/audio_decoder_alsa.cc

Issue 2133293003: [Chromecast] Make ALSA rendering delay either accurate or kNoTimestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/media/cma/backend/alsa/audio_decoder_alsa.h" 5 #include "chromecast/media/cma/backend/alsa/audio_decoder_alsa.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 delegate_ = delegate; 70 delegate_ = delegate;
71 } 71 }
72 72
73 bool AudioDecoderAlsa::Initialize() { 73 bool AudioDecoderAlsa::Initialize() {
74 TRACE_FUNCTION_ENTRY0(); 74 TRACE_FUNCTION_ENTRY0();
75 DCHECK(delegate_); 75 DCHECK(delegate_);
76 stats_ = Statistics(); 76 stats_ = Statistics();
77 is_eos_ = false; 77 is_eos_ = false;
78 last_buffer_pts_ = std::numeric_limits<int64_t>::min(); 78 last_buffer_pts_ = std::numeric_limits<int64_t>::min();
79 79
80 struct timespec now; 80 last_known_delay_.timestamp_microseconds = kInvalidDelayTimestamp;
tianyuwang1 2016/07/08 23:00:00 Can we use media::kNoTimestamp?
kmackay 2016/07/08 23:59:10 I would prefer not to, since media::kNoTimestamp i
81 if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) {
82 last_known_delay_.timestamp_microseconds =
83 static_cast<int64_t>(now.tv_sec) * 1000000 + now.tv_nsec / 1000;
84 } else {
85 LOG(ERROR) << "Failed to get current timestamp";
86 last_known_delay_.timestamp_microseconds = kInvalidDelayTimestamp;
87 return false;
88 }
89 last_known_delay_.delay_microseconds = 0; 81 last_known_delay_.delay_microseconds = 0;
90 return true; 82 return true;
91 } 83 }
92 84
93 bool AudioDecoderAlsa::Start(int64_t start_pts) { 85 bool AudioDecoderAlsa::Start(int64_t start_pts) {
94 TRACE_FUNCTION_ENTRY0(); 86 TRACE_FUNCTION_ENTRY0();
95 current_pts_ = start_pts; 87 current_pts_ = start_pts;
96 DCHECK(IsValidConfig(config_)); 88 DCHECK(IsValidConfig(config_));
97 mixer_input_.reset(new StreamMixerAlsaInput( 89 mixer_input_.reset(new StreamMixerAlsaInput(
98 this, config_.samples_per_second, backend_->Primary())); 90 this, config_.samples_per_second, backend_->Primary()));
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 TRACE_FUNCTION_ENTRY0(); 286 TRACE_FUNCTION_ENTRY0();
295 DCHECK(task_runner_->BelongsToCurrentThread()); 287 DCHECK(task_runner_->BelongsToCurrentThread());
296 if (error != MixerError::kInputIgnored) 288 if (error != MixerError::kInputIgnored)
297 LOG(ERROR) << "Mixer error occurred."; 289 LOG(ERROR) << "Mixer error occurred.";
298 error_ = true; 290 error_ = true;
299 delegate_->OnDecoderError(); 291 delegate_->OnDecoderError();
300 } 292 }
301 293
302 } // namespace media 294 } // namespace media
303 } // namespace chromecast 295 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698