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

Unified Diff: content/browser/media/capture/web_contents_audio_input_stream.cc

Issue 2460033003: Increment/Decrement capturer count when starts/stops audio capturing. (Closed)
Patch Set: Fix. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/capture/web_contents_audio_input_stream.cc
diff --git a/content/browser/media/capture/web_contents_audio_input_stream.cc b/content/browser/media/capture/web_contents_audio_input_stream.cc
index 348af609ed0ce2f46b648fed24496a9108b8131e..b9f15e6cd0607142c1a8194363f36a01239c06a0 100644
--- a/content/browser/media/capture/web_contents_audio_input_stream.cc
+++ b/content/browser/media/capture/web_contents_audio_input_stream.cc
@@ -78,6 +78,10 @@ class WebContentsAudioInputStream::Impl
void StartMirroring();
void StopMirroring();
+ // Increment/decrement the capturer count on the UI BrowserThread.
+ void IncrementCapturerCount();
+ void DecrementCapturerCount();
+
// Invoked on the UI thread to make sure WebContents muting is turned off for
// successful audio capture.
void UnmuteWebContentsAudio();
@@ -165,14 +169,22 @@ bool WebContentsAudioInputStream::Impl::Open() {
return false;
state_ = OPENED;
-
tracker_->Start(
initial_render_process_id_, initial_main_render_frame_id_,
base::Bind(&Impl::OnTargetChanged, this));
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&Impl::IncrementCapturerCount, this));
return true;
}
+void WebContentsAudioInputStream::Impl::IncrementCapturerCount() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (WebContents* contents = tracker_->web_contents())
+ contents->IncrementCapturerCount(gfx::Size());
+}
+
void WebContentsAudioInputStream::Impl::Start(AudioInputCallback* callback) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(callback);
@@ -222,6 +234,8 @@ void WebContentsAudioInputStream::Impl::Close() {
if (state_ == OPENED) {
state_ = CONSTRUCTED;
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&Impl::DecrementCapturerCount, this));
tracker_->Stop();
mixer_stream_->Close();
}
@@ -230,6 +244,13 @@ void WebContentsAudioInputStream::Impl::Close() {
state_ = CLOSED;
}
+void WebContentsAudioInputStream::Impl::DecrementCapturerCount() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (WebContents* contents = tracker_->web_contents())
+ contents->DecrementCapturerCount();
+}
+
void WebContentsAudioInputStream::Impl::ReportError() {
DCHECK(thread_checker_.CalledOnValidThread());
« 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