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

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

Issue 1487983002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in Windows unit test. Created 5 years 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
« no previous file with comments | « no previous file | chromecast/media/audio/cast_audio_output_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | chromecast/media/audio/cast_audio_output_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698