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

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

Issue 416393003: Make Demuxer::Stop() synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('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 (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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 text_enabled_(false), 548 text_enabled_(false),
549 duration_known_(false), 549 duration_known_(false),
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() {
559 DCHECK(task_runner_->BelongsToCurrentThread()); 559 DCHECK(task_runner_->BelongsToCurrentThread());
560 url_protocol_->Abort(); 560 url_protocol_->Abort();
561 data_source_->Stop(); 561 data_source_->Stop();
562 562
563 // This will block until all tasks complete. Note that after this returns it's 563 // 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 564 // 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 565 // thread. Each of the reply task methods must check whether we've stopped the
566 // thread and drop their results on the floor. 566 // thread and drop their results on the floor.
567 blocking_thread_.Stop(); 567 blocking_thread_.Stop();
568 568
569 StreamVector::iterator iter; 569 StreamVector::iterator iter;
570 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 570 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
571 if (*iter) 571 if (*iter)
572 (*iter)->Stop(); 572 (*iter)->Stop();
573 } 573 }
574 574
575 data_source_ = NULL; 575 data_source_ = NULL;
576 task_runner_->PostTask(FROM_HERE, callback);
577 } 576 }
578 577
579 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { 578 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
580 DCHECK(task_runner_->BelongsToCurrentThread()); 579 DCHECK(task_runner_->BelongsToCurrentThread());
581 CHECK(!pending_seek_); 580 CHECK(!pending_seek_);
582 581
583 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|, 582 // TODO(scherkus): Inspect |pending_read_| and cancel IO via |blocking_url_|,
584 // otherwise we can end up waiting for a pre-seek read to complete even though 583 // otherwise we can end up waiting for a pre-seek read to complete even though
585 // we know we're going to drop it on the floor. 584 // we know we're going to drop it on the floor.
586 585
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 } 1226 }
1228 for (size_t i = 0; i < buffered.size(); ++i) 1227 for (size_t i = 0; i < buffered.size(); ++i)
1229 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1228 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1230 } 1229 }
1231 1230
1232 void FFmpegDemuxer::OnDataSourceError() { 1231 void FFmpegDemuxer::OnDataSourceError() {
1233 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1232 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1234 } 1233 }
1235 1234
1236 } // namespace media 1235 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698