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 "content/browser/media/capture/web_contents_audio_muter.h" | 5 #include "content/browser/media/capture/web_contents_audio_muter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/bind_to_current_loop.h" |
9 #include "content/browser/media/capture/audio_mirroring_manager.h" | 10 #include "content/browser/media/capture/audio_mirroring_manager.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "media/audio/audio_io.h" | 14 #include "media/audio/audio_io.h" |
14 #include "media/audio/audio_manager.h" | 15 #include "media/audio/audio_manager.h" |
15 #include "media/audio/fake_audio_worker.h" | 16 #include "media/audio/fake_audio_worker.h" |
16 #include "media/base/bind_to_current_loop.h" | |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // An AudioOutputStream that pumps audio data, but does nothing with it. | 22 // An AudioOutputStream that pumps audio data, but does nothing with it. |
23 // Pumping the audio data is necessary because video playback is synchronized to | 23 // Pumping the audio data is necessary because video playback is synchronized to |
24 // the audio stream and will freeze otherwise. | 24 // the audio stream and will freeze otherwise. |
25 // | 25 // |
26 // TODO(miu): media::FakeAudioOutputStream does pretty much the same thing as | 26 // TODO(miu): media::FakeAudioOutputStream does pretty much the same thing as |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ~MuteDestination() override {} | 79 ~MuteDestination() override {} |
80 | 80 |
81 void QueryForMatches(const std::set<SourceFrameRef>& candidates, | 81 void QueryForMatches(const std::set<SourceFrameRef>& candidates, |
82 const MatchesCallback& results_callback) override { | 82 const MatchesCallback& results_callback) override { |
83 BrowserThread::PostTask( | 83 BrowserThread::PostTask( |
84 BrowserThread::UI, | 84 BrowserThread::UI, |
85 FROM_HERE, | 85 FROM_HERE, |
86 base::Bind(&MuteDestination::QueryForMatchesOnUIThread, | 86 base::Bind(&MuteDestination::QueryForMatchesOnUIThread, |
87 this, | 87 this, |
88 candidates, | 88 candidates, |
89 media::BindToCurrentLoop(results_callback))); | 89 base::BindToCurrentLoop(results_callback))); |
90 } | 90 } |
91 | 91 |
92 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates, | 92 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates, |
93 const MatchesCallback& results_callback) { | 93 const MatchesCallback& results_callback) { |
94 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
95 std::set<SourceFrameRef> matches; | 95 std::set<SourceFrameRef> matches; |
96 // Add each ID to |matches| if it maps to a RenderFrameHost that maps to the | 96 // Add each ID to |matches| if it maps to a RenderFrameHost that maps to the |
97 // WebContents being muted. | 97 // WebContents being muted. |
98 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin(); | 98 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin(); |
99 i != candidates.end(); ++i) { | 99 i != candidates.end(); ++i) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 is_muting_ = false; | 146 is_muting_ = false; |
147 BrowserThread::PostTask( | 147 BrowserThread::PostTask( |
148 BrowserThread::IO, | 148 BrowserThread::IO, |
149 FROM_HERE, | 149 FROM_HERE, |
150 base::Bind(&AudioMirroringManager::StopMirroring, | 150 base::Bind(&AudioMirroringManager::StopMirroring, |
151 base::Unretained(AudioMirroringManager::GetInstance()), | 151 base::Unretained(AudioMirroringManager::GetInstance()), |
152 destination_)); | 152 destination_)); |
153 } | 153 } |
154 | 154 |
155 } // namespace content | 155 } // namespace content |
OLD | NEW |