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

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

Issue 544843005: Avoid FFmpeg destroying active resources during demuxer stop. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo. Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() { 558 void FFmpegDemuxer::Stop() {
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1230 }
1227 for (size_t i = 0; i < buffered.size(); ++i) 1231 for (size_t i = 0; i < buffered.size(); ++i)
1228 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1232 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1229 } 1233 }
1230 1234
1231 void FFmpegDemuxer::OnDataSourceError() { 1235 void FFmpegDemuxer::OnDataSourceError() {
1232 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1236 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1233 } 1237 }
1234 1238
1235 } // namespace media 1239 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698