OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |