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

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

Issue 805273007: Android: Propagate sample rate change to audio decoder job (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 status != MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER); 438 status != MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER);
439 439
440 if (status != MEDIA_CODEC_OK) { 440 if (status != MEDIA_CODEC_OK) {
441 callback.Run(status, kNoTimestamp(), kNoTimestamp()); 441 callback.Run(status, kNoTimestamp(), kNoTimestamp());
442 return; 442 return;
443 } 443 }
444 444
445 // TODO(xhwang/qinmin): This logic is correct but strange. Clean it up. 445 // TODO(xhwang/qinmin): This logic is correct but strange. Clean it up.
446 if (output_eos_encountered_) 446 if (output_eos_encountered_)
447 status = MEDIA_CODEC_OUTPUT_END_OF_STREAM; 447 status = MEDIA_CODEC_OUTPUT_END_OF_STREAM;
448 else if (has_format_change) 448 else if (has_format_change && UpdateOutputFormat())
gunsch 2015/01/12 16:30:51 What's the reason for moving UpdateOutputFormat up
kjoswiak 2015/01/12 19:44:48 Short story, it crashes without this change. Long
449 status = MEDIA_CODEC_OUTPUT_FORMAT_CHANGED; 449 status = MEDIA_CODEC_OUTPUT_FORMAT_CHANGED;
450 450
451 bool render_output = presentation_timestamp >= preroll_timestamp_ && 451 bool render_output = presentation_timestamp >= preroll_timestamp_ &&
452 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u); 452 (status != MEDIA_CODEC_OUTPUT_END_OF_STREAM || size != 0u);
453 base::TimeDelta time_to_render; 453 base::TimeDelta time_to_render;
454 DCHECK(!start_time_ticks.is_null()); 454 DCHECK(!start_time_ticks.is_null());
455 if (render_output && ComputeTimeToRender()) { 455 if (render_output && ComputeTimeToRender()) {
456 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - 456 time_to_render = presentation_timestamp - (base::TimeTicks::Now() -
457 start_time_ticks + start_presentation_timestamp); 457 start_time_ticks + start_presentation_timestamp);
458 } 458 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 DCHECK(false) << "Invalid output status"; 536 DCHECK(false) << "Invalid output status";
537 break; 537 break;
538 }; 538 };
539 539
540 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM && drain_decoder_) { 540 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM && drain_decoder_) {
541 OnDecoderDrained(); 541 OnDecoderDrained();
542 status = MEDIA_CODEC_OK; 542 status = MEDIA_CODEC_OK;
543 } 543 }
544 544
545 if (status == MEDIA_CODEC_OUTPUT_FORMAT_CHANGED) { 545 if (status == MEDIA_CODEC_OUTPUT_FORMAT_CHANGED) {
546 if (UpdateOutputFormat()) 546 config_changed_cb_.Run();
547 config_changed_cb_.Run();
548 status = MEDIA_CODEC_OK; 547 status = MEDIA_CODEC_OK;
549 } 548 }
550 549
551 if (release_resources_pending_) { 550 if (release_resources_pending_) {
552 ReleaseMediaCodecBridge(); 551 ReleaseMediaCodecBridge();
553 release_resources_pending_ = false; 552 release_resources_pending_ = false;
554 if (drain_decoder_) 553 if (drain_decoder_)
555 OnDecoderDrained(); 554 OnDecoderDrained();
556 } 555 }
557 556
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 return CreateMediaCodecBridgeInternal(); 641 return CreateMediaCodecBridgeInternal();
643 } 642 }
644 643
645 bool MediaDecoderJob::IsCodecReconfigureNeeded( 644 bool MediaDecoderJob::IsCodecReconfigureNeeded(
646 const DemuxerConfigs& configs) const { 645 const DemuxerConfigs& configs) const {
647 if (!AreDemuxerConfigsChanged(configs)) 646 if (!AreDemuxerConfigsChanged(configs))
648 return false; 647 return false;
649 return true; 648 return true;
650 } 649 }
651 650
652 bool MediaDecoderJob::UpdateOutputFormat() {
653 return false;
654 }
655
656 void MediaDecoderJob::ReleaseMediaCodecBridge() { 651 void MediaDecoderJob::ReleaseMediaCodecBridge() {
657 if (!media_codec_bridge_) 652 if (!media_codec_bridge_)
658 return; 653 return;
659 654
660 media_codec_bridge_.reset(); 655 media_codec_bridge_.reset();
661 input_buf_index_ = -1; 656 input_buf_index_ = -1;
662 } 657 }
663 658
664 } // namespace media 659 } // namespace media
OLDNEW
« media/base/android/audio_decoder_job.cc ('K') | « media/base/android/media_decoder_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698