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

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

Issue 218763007: Update MediaStreamTrack::Stop to latest draft. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 8 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.cc ('k') | content/renderer/media/media_stream_center.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_stream_audio_source.cc
diff --git a/content/renderer/media/media_stream_audio_source.cc b/content/renderer/media/media_stream_audio_source.cc
index 34f3087d47bb7770cabc487b441c1241a8545ead..a8aa7d6c4d1c0f075100545117d8cf64912e8710 100644
--- a/content/renderer/media/media_stream_audio_source.cc
+++ b/content/renderer/media/media_stream_audio_source.cc
@@ -34,18 +34,23 @@ void MediaStreamAudioSource::AddTrack(
const blink::WebMediaConstraints& constraints,
const ConstraintsCallback& callback) {
// TODO(xians): Properly implement for audio sources.
- if (!factory_)
- callback.Run(this, false);
-
- bool result = true;
if (!local_audio_source_) {
- result = factory_->InitializeMediaStreamAudioSource(render_view_id_,
- constraints,
- this);
+ if (!factory_->InitializeMediaStreamAudioSource(render_view_id_,
+ constraints,
+ this)) {
+ // The source failed to start.
+ // MediaStreamImpl rely on the |stop_callback| to be triggered when the
+ // last track is removed from the source. But in this case, the source is
+ // is not even started. So we need to fail both adding the track and
+ // trigger |stop_callback|.
+ callback.Run(this, false);
+ StopSource();
+ return;
+ }
}
- if (result)
- factory_->CreateLocalAudioTrack(track);
- callback.Run(this, result);
+
+ factory_->CreateLocalAudioTrack(track);
+ callback.Run(this, true);
}
} // namespace content
« no previous file with comments | « content/renderer/media/media_stream.cc ('k') | content/renderer/media/media_stream_center.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698