| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 template <> | 204 template <> |
| 205 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const { | 205 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const { |
| 206 return 1; | 206 return 1; |
| 207 } | 207 } |
| 208 | 208 |
| 209 template <DemuxerStream::Type StreamType> | 209 template <DemuxerStream::Type StreamType> |
| 210 bool DecoderStream<StreamType>::CanDecodeMore() const { | 210 bool DecoderStream<StreamType>::CanDecodeMore() const { |
| 211 DCHECK(task_runner_->BelongsToCurrentThread()); | 211 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 212 | 212 |
| 213 bool buffers_left = !(fallback_buffers_.empty() && decoding_eos_); |
| 214 |
| 213 // Limit total number of outputs stored in |ready_outputs_| and being decoded. | 215 // Limit total number of outputs stored in |ready_outputs_| and being decoded. |
| 214 // It only makes sense to saturate decoder completely when output queue is | 216 // It only makes sense to saturate decoder completely when output queue is |
| 215 // empty. | 217 // empty. |
| 216 int num_decodes = | 218 int num_decodes = |
| 217 static_cast<int>(ready_outputs_.size()) + pending_decode_requests_; | 219 static_cast<int>(ready_outputs_.size()) + pending_decode_requests_; |
| 218 return !decoding_eos_ && num_decodes < GetMaxDecodeRequests(); | 220 return buffers_left && num_decodes < GetMaxDecodeRequests(); |
| 219 } | 221 } |
| 220 | 222 |
| 221 template <DemuxerStream::Type StreamType> | 223 template <DemuxerStream::Type StreamType> |
| 222 base::TimeDelta DecoderStream<StreamType>::AverageDuration() const { | 224 base::TimeDelta DecoderStream<StreamType>::AverageDuration() const { |
| 223 DCHECK(task_runner_->BelongsToCurrentThread()); | 225 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 224 return duration_tracker_.count() ? duration_tracker_.Average() | 226 return duration_tracker_.count() ? duration_tracker_.Average() |
| 225 : base::TimeDelta(); | 227 : base::TimeDelta(); |
| 226 } | 228 } |
| 227 | 229 |
| 228 template <DemuxerStream::Type StreamType> | 230 template <DemuxerStream::Type StreamType> |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 } | 740 } |
| 739 | 741 |
| 740 // The resetting process will be continued in OnDecoderReinitialized(). | 742 // The resetting process will be continued in OnDecoderReinitialized(). |
| 741 ReinitializeDecoder(); | 743 ReinitializeDecoder(); |
| 742 } | 744 } |
| 743 | 745 |
| 744 template class DecoderStream<DemuxerStream::VIDEO>; | 746 template class DecoderStream<DemuxerStream::VIDEO>; |
| 745 template class DecoderStream<DemuxerStream::AUDIO>; | 747 template class DecoderStream<DemuxerStream::AUDIO>; |
| 746 | 748 |
| 747 } // namespace media | 749 } // namespace media |
| OLD | NEW |