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