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

Unified Diff: content/renderer/media/media_stream_source.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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 | « content/renderer/media/media_stream_source.h ('k') | content/renderer/media/mock_audio_device_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_stream_source.cc
diff --git a/content/renderer/media/media_stream_source.cc b/content/renderer/media/media_stream_source.cc
index 8db26024403334efc43050ce36a75bc06301362b..d2b4cbf7f9bac1af284e581a6887e78578ff08ec 100644
--- a/content/renderer/media/media_stream_source.cc
+++ b/content/renderer/media/media_stream_source.cc
@@ -13,14 +13,41 @@ const char MediaStreamSource::kSourceId[] = "sourceId";
MediaStreamSource::MediaStreamSource() {
}
-MediaStreamSource::~MediaStreamSource() {}
+MediaStreamSource::~MediaStreamSource() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ RunStopCallbackAndEndStream();
+}
void MediaStreamSource::StopSource() {
+ DCHECK(thread_checker_.CalledOnValidThread());
DoStopSource();
+ RunStopCallbackAndEndStream();
+}
+
+void MediaStreamSource::SetDeviceInfo(const StreamDeviceInfo& device_info) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ device_info_ = device_info;
+}
+
+void MediaStreamSource::SetStopCallback(
+ const SourceStoppedCallback& stop_callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(stop_callback_.is_null());
+ stop_callback_ = stop_callback;
+}
+
+void MediaStreamSource::ResetSourceStoppedCallback() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(!stop_callback_.is_null());
+ stop_callback_.Reset();
+}
+
+void MediaStreamSource::RunStopCallbackAndEndStream() {
+ DCHECK(thread_checker_.CalledOnValidThread());
if (!stop_callback_.is_null())
base::ResetAndReturn(&stop_callback_).Run(owner());
-
- owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
+ if (!owner().isNull())
+ owner().setReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
}
} // namespace content
« no previous file with comments | « content/renderer/media/media_stream_source.h ('k') | content/renderer/media/mock_audio_device_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698