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

Side by Side Diff: media/base/android/media_decoder_job.cc

Issue 1963343002: Report media error if PlayOutputBuffer failed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Min's comment Created 4 years, 7 months 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 | « media/base/android/media_decoder_job.h ('k') | media/base/android/sdk_media_codec_bridge.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 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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u); 480 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u);
481 base::TimeDelta time_to_render; 481 base::TimeDelta time_to_render;
482 DCHECK(!start_time_ticks.is_null()); 482 DCHECK(!start_time_ticks.is_null());
483 if (render_output && ComputeTimeToRender()) { 483 if (render_output && ComputeTimeToRender()) {
484 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - 484 time_to_render = presentation_timestamp - (base::TimeTicks::Now() -
485 start_time_ticks + start_presentation_timestamp); 485 start_time_ticks + start_presentation_timestamp);
486 } 486 }
487 487
488 if (time_to_render > base::TimeDelta()) { 488 if (time_to_render > base::TimeDelta()) {
489 decoder_task_runner_->PostDelayedTask( 489 decoder_task_runner_->PostDelayedTask(
490 FROM_HERE, 490 FROM_HERE, base::Bind(&MediaDecoderJob::ReleaseOutputBuffer,
491 base::Bind(&MediaDecoderJob::ReleaseOutputBuffer, 491 base::Unretained(this), buffer_index, offset,
492 base::Unretained(this), buffer_index, offset, size, 492 size, render_output,
493 render_output, 493 false, // this is not a late frame
494 false, // this is not a late frame 494 presentation_timestamp, status, callback),
495 presentation_timestamp, base::Bind(callback, status)),
496 time_to_render); 495 time_to_render);
497 return; 496 return;
498 } 497 }
499 498
500 // TODO(qinmin): The codec is lagging behind, need to recalculate the 499 // TODO(qinmin): The codec is lagging behind, need to recalculate the
501 // |start_presentation_timestamp_| and |start_time_ticks_| in 500 // |start_presentation_timestamp_| and |start_time_ticks_| in
502 // media_source_player.cc. 501 // media_source_player.cc.
503 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds(); 502 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds();
504 if (render_output) { 503 if (render_output) {
505 // The player won't expect a timestamp smaller than the 504 // The player won't expect a timestamp smaller than the
506 // |start_presentation_timestamp|. However, this could happen due to decoder 505 // |start_presentation_timestamp|. However, this could happen due to decoder
507 // errors. 506 // errors.
508 presentation_timestamp = std::max( 507 presentation_timestamp = std::max(
509 presentation_timestamp, start_presentation_timestamp); 508 presentation_timestamp, start_presentation_timestamp);
510 } else { 509 } else {
511 presentation_timestamp = kNoTimestamp(); 510 presentation_timestamp = kNoTimestamp();
512 } 511 }
513 512
514 ReleaseOutputCompletionCallback completion_callback = base::Bind(
515 callback, status);
516
517 const bool is_late_frame = (time_to_render < base::TimeDelta()); 513 const bool is_late_frame = (time_to_render < base::TimeDelta());
518 ReleaseOutputBuffer(buffer_index, offset, size, render_output, is_late_frame, 514 ReleaseOutputBuffer(buffer_index, offset, size, render_output, is_late_frame,
519 presentation_timestamp, completion_callback); 515 presentation_timestamp, status, callback);
520 } 516 }
521 517
522 void MediaDecoderJob::OnDecodeCompleted( 518 void MediaDecoderJob::OnDecodeCompleted(
523 MediaCodecStatus status, 519 MediaCodecStatus status,
524 bool is_late_frame, 520 bool is_late_frame,
525 base::TimeDelta current_presentation_timestamp, 521 base::TimeDelta current_presentation_timestamp,
526 base::TimeDelta max_presentation_timestamp) { 522 base::TimeDelta max_presentation_timestamp) {
527 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 523 DCHECK(ui_task_runner_->BelongsToCurrentThread());
528 524
529 if (destroy_pending_) { 525 if (destroy_pending_) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 683
688 void MediaDecoderJob::ReleaseMediaCodecBridge() { 684 void MediaDecoderJob::ReleaseMediaCodecBridge() {
689 if (!media_codec_bridge_) 685 if (!media_codec_bridge_)
690 return; 686 return;
691 687
692 media_codec_bridge_.reset(); 688 media_codec_bridge_.reset();
693 input_buf_index_ = -1; 689 input_buf_index_ = -1;
694 } 690 }
695 691
696 } // namespace media 692 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/sdk_media_codec_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698