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

Side by Side Diff: chromecast/media/audio/cast_audio_output_stream.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix Mac CQ errors. Created 4 years, 2 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/audio/cast_audio_output_stream.h" 5 #include "chromecast/media/audio/cast_audio_output_stream.h"
6 6
7 #include <algorithm>
8 #include <string>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
9 #include "chromecast/base/metrics/cast_metrics_helper.h" 12 #include "chromecast/base/metrics/cast_metrics_helper.h"
10 #include "chromecast/base/task_runner_impl.h" 13 #include "chromecast/base/task_runner_impl.h"
11 #include "chromecast/media/audio/cast_audio_manager.h" 14 #include "chromecast/media/audio/cast_audio_manager.h"
12 #include "chromecast/media/cma/base/decoder_buffer_adapter.h" 15 #include "chromecast/media/cma/base/decoder_buffer_adapter.h"
13 #include "chromecast/public/media/decoder_config.h" 16 #include "chromecast/public/media/decoder_config.h"
14 #include "chromecast/public/media/media_pipeline_backend.h" 17 #include "chromecast/public/media/media_pipeline_backend.h"
15 #include "chromecast/public/media/media_pipeline_device_params.h" 18 #include "chromecast/public/media/media_pipeline_device_params.h"
16 #include "media/base/decoder_buffer.h" 19 #include "media/base/decoder_buffer.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 DCHECK(push_in_progress_); 266 DCHECK(push_in_progress_);
264 267
265 if (!source_callback_) { 268 if (!source_callback_) {
266 push_in_progress_ = false; 269 push_in_progress_ = false;
267 return; 270 return;
268 } 271 }
269 272
270 const base::TimeTicks now = base::TimeTicks::Now(); 273 const base::TimeTicks now = base::TimeTicks::Now();
271 base::TimeDelta queue_delay = 274 base::TimeDelta queue_delay =
272 std::max(base::TimeDelta(), next_push_time_ - now); 275 std::max(base::TimeDelta(), next_push_time_ - now);
273 uint32_t bytes_delay = queue_delay.InMicroseconds() *
274 audio_params_.GetBytesPerSecond() / 1000000;
275 int frame_count = 276 int frame_count =
276 source_callback_->OnMoreData(audio_bus_.get(), bytes_delay, 0); 277 source_callback_->OnMoreData(queue_delay, now, 0, audio_bus_.get());
277 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; 278 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << queue_delay;
278 279
279 DCHECK_EQ(frame_count, audio_bus_->frames()); 280 DCHECK_EQ(frame_count, audio_bus_->frames());
280 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), 281 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()),
281 frame_count * audio_params_.GetBytesPerFrame()); 282 frame_count * audio_params_.GetBytesPerFrame());
282 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, 283 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8,
283 decoder_buffer_->writable_data()); 284 decoder_buffer_->writable_data());
284 decoder_buffer_->set_timestamp(timestamp_helper_.GetTimestamp()); 285 decoder_buffer_->set_timestamp(timestamp_helper_.GetTimestamp());
285 timestamp_helper_.AddFrames(frame_count); 286 timestamp_helper_.AddFrames(frame_count);
286 287
287 auto completion_cb = base::Bind(&CastAudioOutputStream::OnPushBufferComplete, 288 auto completion_cb = base::Bind(&CastAudioOutputStream::OnPushBufferComplete,
(...skipping 25 matching lines...) Expand all
313 314
314 audio_manager_->GetTaskRunner()->PostDelayedTask( 315 audio_manager_->GetTaskRunner()->PostDelayedTask(
315 FROM_HERE, base::Bind(&CastAudioOutputStream::PushBuffer, 316 FROM_HERE, base::Bind(&CastAudioOutputStream::PushBuffer,
316 weak_factory_.GetWeakPtr()), 317 weak_factory_.GetWeakPtr()),
317 delay); 318 delay);
318 push_in_progress_ = true; 319 push_in_progress_ = true;
319 } 320 }
320 321
321 } // namespace media 322 } // namespace media
322 } // namespace chromecast 323 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698