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

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

Issue 2777583002: Move getUserMedia finish to "when audio track configured". (Closed)
Patch Set: Thread-safety on unittest Created 3 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
Index: content/renderer/media/user_media_client_impl.cc
diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc
index 771ed274a147638e3a8f74e7ed8914c47c76a900..bfd0004a6c5a281d11a87de9d461669577e66ce4 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -20,6 +20,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/renderer/media/local_media_stream_audio_source.h"
#include "content/renderer/media/media_stream.h"
+#include "content/renderer/media/media_stream_audio_track.h"
#include "content/renderer/media/media_stream_constraints_util.h"
#include "content/renderer/media/media_stream_constraints_util_video_content.h"
#include "content/renderer/media/media_stream_constraints_util_video_device.h"
@@ -31,6 +32,7 @@
#include "content/renderer/media/webrtc_logging.h"
#include "content/renderer/media/webrtc_uma_histograms.h"
#include "content/renderer/render_thread_impl.h"
+#include "media/base/bind_to_current_loop.h"
#include "media/capture/video_capture_types.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
@@ -711,7 +713,9 @@ void UserMediaClientImpl::OnAudioSourceStarted(
local_sources_.push_back((*it));
pending_local_sources_.erase(it);
- NotifyCurrentRequestInfoOfAudioSourceStarted(source, result, result_name);
+ // The task of notifying the current request is moved.
+ // NotifyCurrentRequestInfoOfAudioSourceStarted(source, result,
Guido Urdaneta 2017/04/06 13:18:57 Use a more descriptive comment. Something like: /
hta - Chromium 2017/04/06 13:57:51 My bad. Deleting the commented-out code instead.
+ // result_name);
return;
}
NOTREACHED();
@@ -1292,10 +1296,14 @@ void UserMediaClientImpl::UserMediaRequestInfo::StartAudioTrack(
sources_.push_back(track.source());
bool connected = native_source->ConnectToTrack(track);
- if (!is_pending) {
- OnTrackStarted(
- native_source,
- connected ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE, "");
+ if (!is_pending && !connected) {
Guido Urdaneta 2017/04/06 13:18:57 Should this be ||? What happens if it is pending b
hta - Chromium 2017/04/06 13:57:51 the previous code was if !pending & connected: ca
+ OnTrackStarted(native_source, MEDIA_DEVICE_TRACK_START_FAILURE, "");
+ } else {
+ MediaStreamAudioTrack::From(track)->SetFormatConfiguredCallback(
+ media::BindToCurrentLoop(base::Bind(
+ &UserMediaClientImpl::UserMediaRequestInfo::OnTrackStarted,
+ AsWeakPtr(), native_source, content::MEDIA_DEVICE_OK,
+ blink::WebString())));
}
}
@@ -1363,7 +1371,9 @@ void UserMediaClientImpl::UserMediaRequestInfo::OnAudioSourceStarted(
// ignore the notification.
auto found = std::find(sources_waiting_for_callback_.begin(),
sources_waiting_for_callback_.end(), source);
- if (found != sources_waiting_for_callback_.end())
+ // If the start failed, inform the request here.
Guido Urdaneta 2017/04/06 13:18:57 Extend the comment with "Otherwise, wait for ... t
+ if (found != sources_waiting_for_callback_.end() &&
+ result != content::MEDIA_DEVICE_OK)
OnTrackStarted(source, result, result_name);
}

Powered by Google App Engine
This is Rietveld 408576698