OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 if (!source_callback_) { | 326 if (!source_callback_) { |
327 push_in_progress_ = false; | 327 push_in_progress_ = false; |
328 return; | 328 return; |
329 } | 329 } |
330 | 330 |
331 const base::TimeTicks now = base::TimeTicks::Now(); | 331 const base::TimeTicks now = base::TimeTicks::Now(); |
332 base::TimeDelta queue_delay = | 332 base::TimeDelta queue_delay = |
333 std::max(base::TimeDelta(), next_push_time_ - now); | 333 std::max(base::TimeDelta(), next_push_time_ - now); |
334 uint32_t bytes_delay = queue_delay.InMicroseconds() * | 334 uint32_t bytes_delay = queue_delay.InMicroseconds() * |
335 audio_params_.GetBytesPerSecond() / 1000000; | 335 audio_params_.GetBytesPerSecond() / 1000000; |
336 int frame_count = source_callback_->OnMoreData(audio_bus_.get(), bytes_delay); | 336 int frame_count = |
| 337 source_callback_->OnMoreData(audio_bus_.get(), bytes_delay, 0); |
337 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; | 338 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; |
338 | 339 |
339 DCHECK_EQ(frame_count, audio_bus_->frames()); | 340 DCHECK_EQ(frame_count, audio_bus_->frames()); |
340 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), | 341 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), |
341 frame_count * audio_params_.GetBytesPerFrame()); | 342 frame_count * audio_params_.GetBytesPerFrame()); |
342 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, | 343 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, |
343 decoder_buffer_->writable_data()); | 344 decoder_buffer_->writable_data()); |
344 | 345 |
345 auto completion_cb = ::media::BindToCurrentLoop( | 346 auto completion_cb = ::media::BindToCurrentLoop( |
346 base::Bind(&CastAudioOutputStream::OnPushBufferComplete, | 347 base::Bind(&CastAudioOutputStream::OnPushBufferComplete, |
(...skipping 30 matching lines...) Expand all Loading... |
377 audio_task_runner_->PostDelayedTask( | 378 audio_task_runner_->PostDelayedTask( |
378 FROM_HERE, | 379 FROM_HERE, |
379 base::Bind(&CastAudioOutputStream::PushBuffer, | 380 base::Bind(&CastAudioOutputStream::PushBuffer, |
380 weak_factory_.GetWeakPtr()), | 381 weak_factory_.GetWeakPtr()), |
381 delay); | 382 delay); |
382 push_in_progress_ = true; | 383 push_in_progress_ = true; |
383 } | 384 } |
384 | 385 |
385 } // namespace media | 386 } // namespace media |
386 } // namespace chromecast | 387 } // namespace chromecast |
OLD | NEW |