| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <climits> | 6 #include <climits> |
| 7 #include <cstdarg> | 7 #include <cstdarg> |
| 8 #include <cstdio> | 8 #include <cstdio> |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 audio_playout_queue_.push_back( | 309 audio_playout_queue_.push_back( |
| 310 std::make_pair(playout_time, audio_frame.release())); | 310 std::make_pair(playout_time, audio_frame.release())); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // End of InProcessReceiver overrides. | 313 // End of InProcessReceiver overrides. |
| 314 //////////////////////////////////////////////////////////////////// | 314 //////////////////////////////////////////////////////////////////// |
| 315 | 315 |
| 316 //////////////////////////////////////////////////////////////////// | 316 //////////////////////////////////////////////////////////////////// |
| 317 // AudioSourceCallback implementation. | 317 // AudioSourceCallback implementation. |
| 318 | 318 |
| 319 virtual int OnMoreData(AudioBus* dest, int total_bytes_delay) | 319 virtual int OnMoreData(AudioBus* dest, AudioBuffersState buffers_state) |
| 320 OVERRIDE { | 320 OVERRIDE { |
| 321 // Note: This method is being invoked by a separate thread unknown to us | 321 // Note: This method is being invoked by a separate thread unknown to us |
| 322 // (i.e., outside of CastEnvironment). | 322 // (i.e., outside of CastEnvironment). |
| 323 | 323 |
| 324 int samples_remaining = dest->frames(); | 324 int samples_remaining = dest->frames(); |
| 325 | 325 |
| 326 while (samples_remaining > 0) { | 326 while (samples_remaining > 0) { |
| 327 // Get next audio frame ready for playout. | 327 // Get next audio frame ready for playout. |
| 328 if (!currently_playing_audio_frame_.get()) { | 328 if (!currently_playing_audio_frame_.get()) { |
| 329 base::AutoLock auto_lock(audio_lock_); | 329 base::AutoLock auto_lock(audio_lock_); |
| 330 | 330 |
| 331 // Prune the queue, skipping entries that are too old. | 331 // Prune the queue, skipping entries that are too old. |
| 332 // TODO(miu): Use |total_bytes_delay| to account for audio buffering | 332 // TODO(miu): Use |buffers_state| to account for audio buffering delays |
| 333 // delays upstream. | 333 // upstream. |
| 334 const base::TimeTicks earliest_time_to_play = | 334 const base::TimeTicks earliest_time_to_play = |
| 335 cast_env()->Clock()->NowTicks() - max_frame_age_; | 335 cast_env()->Clock()->NowTicks() - max_frame_age_; |
| 336 while (!audio_playout_queue_.empty() && | 336 while (!audio_playout_queue_.empty() && |
| 337 audio_playout_queue_.front().first < earliest_time_to_play) { | 337 audio_playout_queue_.front().first < earliest_time_to_play) { |
| 338 PopOneAudioFrame(true); | 338 PopOneAudioFrame(true); |
| 339 } | 339 } |
| 340 if (audio_playout_queue_.empty()) | 340 if (audio_playout_queue_.empty()) |
| 341 break; | 341 break; |
| 342 | 342 |
| 343 currently_playing_audio_frame_ = PopOneAudioFrame(false).Pass(); | 343 currently_playing_audio_frame_ = PopOneAudioFrame(false).Pass(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 audio_config, | 592 audio_config, |
| 593 video_config, | 593 video_config, |
| 594 window_width, | 594 window_width, |
| 595 window_height); | 595 window_height); |
| 596 player.Start(); | 596 player.Start(); |
| 597 | 597 |
| 598 base::MessageLoop().Run(); // Run forever (i.e., until SIGTERM). | 598 base::MessageLoop().Run(); // Run forever (i.e., until SIGTERM). |
| 599 NOTREACHED(); | 599 NOTREACHED(); |
| 600 return 0; | 600 return 0; |
| 601 } | 601 } |
| OLD | NEW |