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/base/pipeline_impl.h" | 5 #include "media/base/pipeline_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void PipelineImpl::Stop() { | 88 void PipelineImpl::Stop() { |
89 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 89 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
90 DVLOG(2) << __FUNCTION__; | 90 DVLOG(2) << __FUNCTION__; |
91 | 91 |
92 if (media_task_runner_ != main_task_runner_) { | 92 if (media_task_runner_ != main_task_runner_) { |
93 // This path is executed by production code where the two task runners - | 93 // This path is executed by production code where the two task runners - |
94 // main and media - live on different threads. | 94 // main and media - live on different threads. |
95 // TODO(alokp): It may be possible to not have to wait for StopTask by | 95 // TODO(alokp): It may be possible to not have to wait for StopTask by |
96 // moving the members accessed on media thread into a class/struct and | 96 // moving the members accessed on media thread into a class/struct and |
97 // DeleteSoon the instance on the media thread. | 97 // DeleteSoon the instance on the media thread. |
98 base::WaitableEvent waiter(false, false); | 98 base::WaitableEvent waiter(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 99 base::WaitableEvent::InitialState::NOT_SIGNALED); |
99 base::Closure stop_cb = | 100 base::Closure stop_cb = |
100 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&waiter)); | 101 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&waiter)); |
101 // If posting the task fails or the posted task fails to run, | 102 // If posting the task fails or the posted task fails to run, |
102 // we will wait here forever. So add a CHECK to make sure we do not run | 103 // we will wait here forever. So add a CHECK to make sure we do not run |
103 // into those situations. | 104 // into those situations. |
104 CHECK(weak_factory_.HasWeakPtrs()); | 105 CHECK(weak_factory_.HasWeakPtrs()); |
105 CHECK(media_task_runner_->PostTask( | 106 CHECK(media_task_runner_->PostTask( |
106 FROM_HERE, base::Bind(&PipelineImpl::StopTask, weak_this_, stop_cb))); | 107 FROM_HERE, base::Bind(&PipelineImpl::StopTask, weak_this_, stop_cb))); |
107 waiter.Wait(); | 108 waiter.Wait(); |
108 } else { | 109 } else { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 if (demuxer_->GetStream(DemuxerStream::AUDIO)) { | 951 if (demuxer_->GetStream(DemuxerStream::AUDIO)) { |
951 metadata.has_audio = true; | 952 metadata.has_audio = true; |
952 } | 953 } |
953 | 954 |
954 main_task_runner_->PostTask( | 955 main_task_runner_->PostTask( |
955 FROM_HERE, | 956 FROM_HERE, |
956 base::Bind(&Pipeline::Client::OnMetadata, weak_client_, metadata)); | 957 base::Bind(&Pipeline::Client::OnMetadata, weak_client_, metadata)); |
957 } | 958 } |
958 | 959 |
959 } // namespace media | 960 } // namespace media |
OLD | NEW |