OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ffmpeg_demuxer.h" | 5 #include "media/filters/ffmpeg_demuxer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 need_key_cb_(need_key_cb), | 550 need_key_cb_(need_key_cb), |
551 weak_factory_(this) { | 551 weak_factory_(this) { |
552 DCHECK(task_runner_.get()); | 552 DCHECK(task_runner_.get()); |
553 DCHECK(data_source_); | 553 DCHECK(data_source_); |
554 } | 554 } |
555 | 555 |
556 FFmpegDemuxer::~FFmpegDemuxer() {} | 556 FFmpegDemuxer::~FFmpegDemuxer() {} |
557 | 557 |
558 void FFmpegDemuxer::Stop(const base::Closure& callback) { | 558 void FFmpegDemuxer::Stop(const base::Closure& callback) { |
559 DCHECK(task_runner_->BelongsToCurrentThread()); | 559 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 560 |
| 561 // The order of Stop() and Abort() is important here. If Abort() is called |
| 562 // first, control may pass into FFmpeg where it can destruct buffers that are |
| 563 // in the process of being fulfilled by the DataSource. |
| 564 data_source_->Stop(); |
560 url_protocol_->Abort(); | 565 url_protocol_->Abort(); |
561 data_source_->Stop(); | |
562 | 566 |
563 // This will block until all tasks complete. Note that after this returns it's | 567 // This will block until all tasks complete. Note that after this returns it's |
564 // possible for reply tasks (e.g., OnReadFrameDone()) to be queued on this | 568 // possible for reply tasks (e.g., OnReadFrameDone()) to be queued on this |
565 // thread. Each of the reply task methods must check whether we've stopped the | 569 // thread. Each of the reply task methods must check whether we've stopped the |
566 // thread and drop their results on the floor. | 570 // thread and drop their results on the floor. |
567 blocking_thread_.Stop(); | 571 blocking_thread_.Stop(); |
568 | 572 |
569 StreamVector::iterator iter; | 573 StreamVector::iterator iter; |
570 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { | 574 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { |
571 if (*iter) | 575 if (*iter) |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 } | 1231 } |
1228 for (size_t i = 0; i < buffered.size(); ++i) | 1232 for (size_t i = 0; i < buffered.size(); ++i) |
1229 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 1233 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
1230 } | 1234 } |
1231 | 1235 |
1232 void FFmpegDemuxer::OnDataSourceError() { | 1236 void FFmpegDemuxer::OnDataSourceError() { |
1233 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 1237 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
1234 } | 1238 } |
1235 | 1239 |
1236 } // namespace media | 1240 } // namespace media |
OLD | NEW |