| Index: media/audio/cras/cras_unified.cc
|
| diff --git a/media/audio/cras/cras_unified.cc b/media/audio/cras/cras_unified.cc
|
| index ccaf11c604eb06ffba91a91b5f3f9d97d6e52917..b8ef63ca8bf0deba6ecada43f73fa47c969137fa 100644
|
| --- a/media/audio/cras/cras_unified.cc
|
| +++ b/media/audio/cras/cras_unified.cc
|
| @@ -61,7 +61,7 @@ CrasUnifiedStream::CrasUnifiedStream(const AudioParameters& params,
|
| source_callback_(NULL),
|
| stream_direction_(CRAS_STREAM_OUTPUT) {
|
| DCHECK(manager_);
|
| - DCHECK(params_.channels() > 0);
|
| + DCHECK_GT(params_.channels(), 0);
|
|
|
| output_bus_ = AudioBus::Create(params);
|
| }
|
| @@ -233,21 +233,14 @@ void CrasUnifiedStream::GetVolume(double* volume) {
|
| *volume = volume_;
|
| }
|
|
|
| -uint32_t CrasUnifiedStream::GetBytesLatency(const struct timespec& latency_ts) {
|
| - uint32_t latency_usec;
|
| -
|
| +base::TimeTicks CrasUnifiedStream::GetTargetPlayoutTime(
|
| + const struct timespec& latency_ts) {
|
| // Treat negative latency (if we are too slow to render) as 0.
|
| if (latency_ts.tv_sec < 0 || latency_ts.tv_nsec < 0) {
|
| - latency_usec = 0;
|
| - } else {
|
| - latency_usec = (latency_ts.tv_sec * base::Time::kMicrosecondsPerSecond) +
|
| - latency_ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
|
| + return base::TimeTicks::Now();
|
| }
|
|
|
| - double frames_latency =
|
| - latency_usec * params_.sample_rate() / base::Time::kMicrosecondsPerSecond;
|
| -
|
| - return static_cast<unsigned int>(frames_latency * bytes_per_frame_);
|
| + return base::TimeTicks::Now() + base::TimeDelta::FromTimeSpec(latency_ts);
|
| }
|
|
|
| // Static callback asking for samples.
|
| @@ -306,7 +299,7 @@ uint32_t CrasUnifiedStream::WriteAudio(size_t frames,
|
| cras_client_calc_playback_latency(sample_ts, &latency_ts);
|
|
|
| int frames_filled = source_callback_->OnMoreData(
|
| - output_bus_.get(), GetBytesLatency(latency_ts), 0);
|
| + GetTargetPlayoutTime(latency_ts), 0, output_bus_.get());
|
|
|
| // Note: If this ever changes to output raw float the data must be clipped and
|
| // sanitized since it may come from an untrusted source such as NaCl.
|
|
|