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

Side by Side Diff: media/filters/decoder_stream.cc

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/filters/decoder_stream.h ('k') | media/filters/decoder_stream_traits.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/filters/decoder_stream.h" 5 #include "media/filters/decoder_stream.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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 state_ = STATE_REINITIALIZING_DECODER; 499 state_ = STATE_REINITIALIZING_DECODER;
500 DecoderStreamTraits<StreamType>::InitializeDecoder( 500 DecoderStreamTraits<StreamType>::InitializeDecoder(
501 decoder_.get(), stream_, 501 decoder_.get(), stream_,
502 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, 502 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized,
503 weak_factory_.GetWeakPtr()), 503 weak_factory_.GetWeakPtr()),
504 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, 504 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady,
505 weak_factory_.GetWeakPtr())); 505 weak_factory_.GetWeakPtr()));
506 } 506 }
507 507
508 template <DemuxerStream::Type StreamType> 508 template <DemuxerStream::Type StreamType>
509 void DecoderStream<StreamType>::OnDecoderReinitialized(PipelineStatus status) { 509 void DecoderStream<StreamType>::OnDecoderReinitialized(bool success) {
510 FUNCTION_DVLOG(2); 510 FUNCTION_DVLOG(2);
511 DCHECK(task_runner_->BelongsToCurrentThread()); 511 DCHECK(task_runner_->BelongsToCurrentThread());
512 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); 512 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER);
513 513
514 // ReinitializeDecoder() can be called in two cases: 514 // ReinitializeDecoder() can be called in two cases:
515 // 1, Flushing decoder finished (see OnDecodeOutputReady()). 515 // 1, Flushing decoder finished (see OnDecodeOutputReady()).
516 // 2, Reset() was called during flushing decoder (see OnDecoderReset()). 516 // 2, Reset() was called during flushing decoder (see OnDecoderReset()).
517 // Also, Reset() can be called during pending ReinitializeDecoder(). 517 // Also, Reset() can be called during pending ReinitializeDecoder().
518 // This function needs to handle them all! 518 // This function needs to handle them all!
519 519
520 if (status != PIPELINE_OK) { 520 if (!success) {
521 // Reinitialization failed. Try to fall back to one of the remaining 521 // Reinitialization failed. Try to fall back to one of the remaining
522 // decoders. This will consume at least one decoder so doing it more than 522 // decoders. This will consume at least one decoder so doing it more than
523 // once is safe. 523 // once is safe.
524 // For simplicity, don't attempt to fall back to a decryptor. Calling this 524 // For simplicity, don't attempt to fall back to a decryptor. Calling this
525 // with a null callback ensures that one won't be selected. 525 // with a null callback ensures that one won't be selected.
526 SelectDecoder(SetDecryptorReadyCB()); 526 SelectDecoder(SetDecryptorReadyCB());
527 } else { 527 } else {
528 CompleteDecoderReinitialization(true); 528 CompleteDecoderReinitialization(true);
529 } 529 }
530 } 530 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 584 }
585 585
586 // The resetting process will be continued in OnDecoderReinitialized(). 586 // The resetting process will be continued in OnDecoderReinitialized().
587 ReinitializeDecoder(); 587 ReinitializeDecoder();
588 } 588 }
589 589
590 template class DecoderStream<DemuxerStream::VIDEO>; 590 template class DecoderStream<DemuxerStream::VIDEO>;
591 template class DecoderStream<DemuxerStream::AUDIO>; 591 template class DecoderStream<DemuxerStream::AUDIO>;
592 592
593 } // namespace media 593 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_stream.h ('k') | media/filters/decoder_stream_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698