| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <climits> | 10 #include <climits> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // delays upstream. | 338 // delays upstream. |
| 339 const base::TimeTicks earliest_time_to_play = | 339 const base::TimeTicks earliest_time_to_play = |
| 340 cast_env()->Clock()->NowTicks() - max_frame_age_; | 340 cast_env()->Clock()->NowTicks() - max_frame_age_; |
| 341 while (!audio_playout_queue_.empty() && | 341 while (!audio_playout_queue_.empty() && |
| 342 audio_playout_queue_.front().first < earliest_time_to_play) { | 342 audio_playout_queue_.front().first < earliest_time_to_play) { |
| 343 PopOneAudioFrame(true); | 343 PopOneAudioFrame(true); |
| 344 } | 344 } |
| 345 if (audio_playout_queue_.empty()) | 345 if (audio_playout_queue_.empty()) |
| 346 break; | 346 break; |
| 347 | 347 |
| 348 currently_playing_audio_frame_ = PopOneAudioFrame(false).Pass(); | 348 currently_playing_audio_frame_ = PopOneAudioFrame(false); |
| 349 currently_playing_audio_frame_start_ = 0; | 349 currently_playing_audio_frame_start_ = 0; |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Copy some or all of the samples in |currently_playing_audio_frame_| to | 352 // Copy some or all of the samples in |currently_playing_audio_frame_| to |
| 353 // |dest|. Once all samples in |currently_playing_audio_frame_| have been | 353 // |dest|. Once all samples in |currently_playing_audio_frame_| have been |
| 354 // consumed, release it. | 354 // consumed, release it. |
| 355 const int num_samples_to_copy = | 355 const int num_samples_to_copy = |
| 356 std::min(samples_remaining, | 356 std::min(samples_remaining, |
| 357 currently_playing_audio_frame_->frames() - | 357 currently_playing_audio_frame_->frames() - |
| 358 currently_playing_audio_frame_start_); | 358 currently_playing_audio_frame_start_); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 << " usec)]: Playing " | 465 << " usec)]: Playing " |
| 466 << (cast_env()->Clock()->NowTicks() - | 466 << (cast_env()->Clock()->NowTicks() - |
| 467 audio_playout_queue_.front().first).InMicroseconds() | 467 audio_playout_queue_.front().first).InMicroseconds() |
| 468 << " usec later than intended."; | 468 << " usec later than intended."; |
| 469 } | 469 } |
| 470 | 470 |
| 471 last_popped_audio_playout_time_ = audio_playout_queue_.front().first; | 471 last_popped_audio_playout_time_ = audio_playout_queue_.front().first; |
| 472 scoped_ptr<AudioBus> ret(audio_playout_queue_.front().second); | 472 scoped_ptr<AudioBus> ret(audio_playout_queue_.front().second); |
| 473 audio_playout_queue_.pop_front(); | 473 audio_playout_queue_.pop_front(); |
| 474 ++num_audio_frames_processed_; | 474 ++num_audio_frames_processed_; |
| 475 return ret.Pass(); | 475 return ret; |
| 476 } | 476 } |
| 477 | 477 |
| 478 void CheckAVSync() { | 478 void CheckAVSync() { |
| 479 if (video_play_times_.size() > 30 && | 479 if (video_play_times_.size() > 30 && |
| 480 audio_play_times_.size() > 30) { | 480 audio_play_times_.size() > 30) { |
| 481 size_t num_events = 0; | 481 size_t num_events = 0; |
| 482 base::TimeDelta delta; | 482 base::TimeDelta delta; |
| 483 std::map<uint16_t, base::TimeTicks>::iterator audio_iter, video_iter; | 483 std::map<uint16_t, base::TimeTicks>::iterator audio_iter, video_iter; |
| 484 for (video_iter = video_play_times_.begin(); | 484 for (video_iter = video_play_times_.begin(); |
| 485 video_iter != video_play_times_.end(); | 485 video_iter != video_play_times_.end(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 audio_config, | 597 audio_config, |
| 598 video_config, | 598 video_config, |
| 599 window_width, | 599 window_width, |
| 600 window_height); | 600 window_height); |
| 601 player.Start(); | 601 player.Start(); |
| 602 | 602 |
| 603 base::MessageLoop().Run(); // Run forever (i.e., until SIGTERM). | 603 base::MessageLoop().Run(); // Run forever (i.e., until SIGTERM). |
| 604 NOTREACHED(); | 604 NOTREACHED(); |
| 605 return 0; | 605 return 0; |
| 606 } | 606 } |
| OLD | NEW |