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

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

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/media_player_bridge.h » ('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/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 13 matching lines...) Expand all
24 MediaCodecBridge* media_codec_bridge, 24 MediaCodecBridge* media_codec_bridge,
25 const base::Closure& request_data_cb) 25 const base::Closure& request_data_cb)
26 : ui_task_runner_(base::MessageLoopProxy::current()), 26 : ui_task_runner_(base::MessageLoopProxy::current()),
27 decoder_task_runner_(decoder_task_runner), 27 decoder_task_runner_(decoder_task_runner),
28 media_codec_bridge_(media_codec_bridge), 28 media_codec_bridge_(media_codec_bridge),
29 needs_flush_(false), 29 needs_flush_(false),
30 input_eos_encountered_(false), 30 input_eos_encountered_(false),
31 output_eos_encountered_(false), 31 output_eos_encountered_(false),
32 skip_eos_enqueue_(true), 32 skip_eos_enqueue_(true),
33 prerolling_(true), 33 prerolling_(true),
34 weak_this_(this),
35 request_data_cb_(request_data_cb), 34 request_data_cb_(request_data_cb),
36 access_unit_index_(0), 35 access_unit_index_(0),
37 input_buf_index_(-1), 36 input_buf_index_(-1),
38 stop_decode_pending_(false), 37 stop_decode_pending_(false),
39 destroy_pending_(false) { 38 destroy_pending_(false),
40 } 39 weak_factory_(this) {}
41 40
42 MediaDecoderJob::~MediaDecoderJob() {} 41 MediaDecoderJob::~MediaDecoderJob() {}
43 42
44 void MediaDecoderJob::OnDataReceived(const DemuxerData& data) { 43 void MediaDecoderJob::OnDataReceived(const DemuxerData& data) {
45 DVLOG(1) << __FUNCTION__ << ": " << data.access_units.size() << " units"; 44 DVLOG(1) << __FUNCTION__ << ": " << data.access_units.size() << " units";
46 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 45 DCHECK(ui_task_runner_->BelongsToCurrentThread());
47 DCHECK(!on_data_received_cb_.is_null()); 46 DCHECK(!on_data_received_cb_.is_null());
48 47
49 TRACE_EVENT_ASYNC_END2( 48 TRACE_EVENT_ASYNC_END2(
50 "media", "MediaDecoderJob::RequestData", this, 49 "media", "MediaDecoderJob::RequestData", this,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 DCHECK(!start_time_ticks.is_null()); 354 DCHECK(!start_time_ticks.is_null());
356 if (render_output && ComputeTimeToRender()) { 355 if (render_output && ComputeTimeToRender()) {
357 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - 356 time_to_render = presentation_timestamp - (base::TimeTicks::Now() -
358 start_time_ticks + start_presentation_timestamp); 357 start_time_ticks + start_presentation_timestamp);
359 } 358 }
360 359
361 if (time_to_render > base::TimeDelta()) { 360 if (time_to_render > base::TimeDelta()) {
362 decoder_task_runner_->PostDelayedTask( 361 decoder_task_runner_->PostDelayedTask(
363 FROM_HERE, 362 FROM_HERE,
364 base::Bind(&MediaDecoderJob::ReleaseOutputBuffer, 363 base::Bind(&MediaDecoderJob::ReleaseOutputBuffer,
365 weak_this_.GetWeakPtr(), buffer_index, size, render_output, 364 weak_factory_.GetWeakPtr(),
365 buffer_index,
366 size,
367 render_output,
366 base::Bind(callback, status, presentation_timestamp)), 368 base::Bind(callback, status, presentation_timestamp)),
367 time_to_render); 369 time_to_render);
368 return; 370 return;
369 } 371 }
370 372
371 // TODO(qinmin): The codec is lagging behind, need to recalculate the 373 // TODO(qinmin): The codec is lagging behind, need to recalculate the
372 // |start_presentation_timestamp_| and |start_time_ticks_| in 374 // |start_presentation_timestamp_| and |start_time_ticks_| in
373 // media_source_player.cc. 375 // media_source_player.cc.
374 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds(); 376 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds();
375 if (render_output) { 377 if (render_output) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // Do nothing. 423 // Do nothing.
422 break; 424 break;
423 }; 425 };
424 426
425 stop_decode_pending_ = false; 427 stop_decode_pending_ = false;
426 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp, 428 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp,
427 audio_output_bytes); 429 audio_output_bytes);
428 } 430 }
429 431
430 } // namespace media 432 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/media_player_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698