Chromium Code Reviews| 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 "media/base/android/media_decoder_job.h" | 5 #include "media/base/android/media_decoder_job.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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 callback.Run(status, kNoTimestamp(), 0); | 343 callback.Run(status, kNoTimestamp(), 0); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 | 346 |
| 347 // TODO(xhwang/qinmin): This logic is correct but strange. Clean it up. | 347 // TODO(xhwang/qinmin): This logic is correct but strange. Clean it up. |
| 348 if (output_eos_encountered_) | 348 if (output_eos_encountered_) |
| 349 status = MEDIA_CODEC_OUTPUT_END_OF_STREAM; | 349 status = MEDIA_CODEC_OUTPUT_END_OF_STREAM; |
| 350 else if (input_status == MEDIA_CODEC_INPUT_END_OF_STREAM) | 350 else if (input_status == MEDIA_CODEC_INPUT_END_OF_STREAM) |
| 351 status = MEDIA_CODEC_INPUT_END_OF_STREAM; | 351 status = MEDIA_CODEC_INPUT_END_OF_STREAM; |
| 352 | 352 |
| 353 // Check whether we need to render the output. | 353 bool render_output = presentation_timestamp >= preroll_timestamp_ && |
|
wolenetz
2014/01/02 19:24:53
The previous implementation had a comment mentioni
qinmin
2014/01/02 22:57:01
audio timestamp is equal to input AU's timestamp,
| |
| 354 // TODO(qinmin): comparing most recently queued input's |unit.timestamp| with | |
| 355 // |preroll_timestamp_| is not accurate due to data reordering and possible | |
| 356 // input queueing without immediate dequeue when |input_status| != | |
| 357 // |MEDIA_CODEC_OK|. Need to use the |presentation_timestamp| for video, and | |
| 358 // use |size| to calculate the timestamp for audio. See | |
| 359 // http://crbug.com/310823 and http://b/11356652. | |
| 360 bool render_output = unit.timestamp >= preroll_timestamp_ && | |
| 361 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u); | 354 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u); |
| 362 base::TimeDelta time_to_render; | 355 base::TimeDelta time_to_render; |
| 363 DCHECK(!start_time_ticks.is_null()); | 356 DCHECK(!start_time_ticks.is_null()); |
| 364 if (render_output && ComputeTimeToRender()) { | 357 if (render_output && ComputeTimeToRender()) { |
| 365 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - | 358 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - |
| 366 start_time_ticks + start_presentation_timestamp); | 359 start_time_ticks + start_presentation_timestamp); |
| 367 } | 360 } |
| 368 | 361 |
| 369 if (time_to_render > base::TimeDelta()) { | 362 if (time_to_render > base::TimeDelta()) { |
| 370 decoder_task_runner_->PostDelayedTask( | 363 decoder_task_runner_->PostDelayedTask( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 // Do nothing. | 422 // Do nothing. |
| 430 break; | 423 break; |
| 431 }; | 424 }; |
| 432 | 425 |
| 433 stop_decode_pending_ = false; | 426 stop_decode_pending_ = false; |
| 434 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp, | 427 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp, |
| 435 audio_output_bytes); | 428 audio_output_bytes); |
| 436 } | 429 } |
| 437 | 430 |
| 438 } // namespace media | 431 } // namespace media |
| OLD | NEW |