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 = | 334 int frame_count = source_callback_->OnMoreData(audio_bus_.get(), bytes_delay); |
335 source_callback_->OnMoreData(audio_bus_.get(), bytes_delay, 0); | |
336 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; | 335 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; |
337 | 336 |
338 DCHECK_EQ(frame_count, audio_bus_->frames()); | 337 DCHECK_EQ(frame_count, audio_bus_->frames()); |
339 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), | 338 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), |
340 frame_count * audio_params_.GetBytesPerFrame()); | 339 frame_count * audio_params_.GetBytesPerFrame()); |
341 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, | 340 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, |
342 decoder_buffer_->writable_data()); | 341 decoder_buffer_->writable_data()); |
343 | 342 |
344 auto completion_cb = ::media::BindToCurrentLoop( | 343 auto completion_cb = ::media::BindToCurrentLoop( |
345 base::Bind(&CastAudioOutputStream::OnPushBufferComplete, | 344 base::Bind(&CastAudioOutputStream::OnPushBufferComplete, |
(...skipping 30 matching lines...) Expand all Loading... |
376 audio_task_runner_->PostDelayedTask( | 375 audio_task_runner_->PostDelayedTask( |
377 FROM_HERE, | 376 FROM_HERE, |
378 base::Bind(&CastAudioOutputStream::PushBuffer, | 377 base::Bind(&CastAudioOutputStream::PushBuffer, |
379 weak_factory_.GetWeakPtr()), | 378 weak_factory_.GetWeakPtr()), |
380 delay); | 379 delay); |
381 push_in_progress_ = true; | 380 push_in_progress_ = true; |
382 } | 381 } |
383 | 382 |
384 } // namespace media | 383 } // namespace media |
385 } // namespace chromecast | 384 } // namespace chromecast |
OLD | NEW |