| 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 <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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() * | 276 uint32_t bytes_delay = queue_delay.InMicroseconds() * |
| 274 audio_params_.GetBytesPerSecond() / 1000000; | 277 audio_params_.GetBytesPerSecond() / 1000000; |
| 275 int frame_count = | 278 int frame_count = source_callback_->OnMoreData(audio_bus_.get(), bytes_delay, |
| 276 source_callback_->OnMoreData(audio_bus_.get(), bytes_delay, 0); | 279 base::TimeDelta(), 0); |
| 277 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; | 280 VLOG(3) << "frames_filled=" << frame_count << " with latency=" << bytes_delay; |
| 278 | 281 |
| 279 DCHECK_EQ(frame_count, audio_bus_->frames()); | 282 DCHECK_EQ(frame_count, audio_bus_->frames()); |
| 280 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), | 283 DCHECK_EQ(static_cast<int>(decoder_buffer_->data_size()), |
| 281 frame_count * audio_params_.GetBytesPerFrame()); | 284 frame_count * audio_params_.GetBytesPerFrame()); |
| 282 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, | 285 audio_bus_->ToInterleaved(frame_count, audio_params_.bits_per_sample() / 8, |
| 283 decoder_buffer_->writable_data()); | 286 decoder_buffer_->writable_data()); |
| 284 decoder_buffer_->set_timestamp(timestamp_helper_.GetTimestamp()); | 287 decoder_buffer_->set_timestamp(timestamp_helper_.GetTimestamp()); |
| 285 timestamp_helper_.AddFrames(frame_count); | 288 timestamp_helper_.AddFrames(frame_count); |
| 286 | 289 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 313 | 316 |
| 314 audio_manager_->GetTaskRunner()->PostDelayedTask( | 317 audio_manager_->GetTaskRunner()->PostDelayedTask( |
| 315 FROM_HERE, base::Bind(&CastAudioOutputStream::PushBuffer, | 318 FROM_HERE, base::Bind(&CastAudioOutputStream::PushBuffer, |
| 316 weak_factory_.GetWeakPtr()), | 319 weak_factory_.GetWeakPtr()), |
| 317 delay); | 320 delay); |
| 318 push_in_progress_ = true; | 321 push_in_progress_ = true; |
| 319 } | 322 } |
| 320 | 323 |
| 321 } // namespace media | 324 } // namespace media |
| 322 } // namespace chromecast | 325 } // namespace chromecast |
| OLD | NEW |