Make sure input manager lock is accessed after channel manager lock.

This CL reverses the lock order in vie_capture_impl.cc to make sure the
different manager locks are always accessed in the same order.

R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/47519004

Cr-Commit-Position: refs/heads/master@{#8685}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8685 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/video_engine/vie_capture_impl.cc b/webrtc/video_engine/vie_capture_impl.cc
index 171d646..aa330cc 100644
--- a/webrtc/video_engine/vie_capture_impl.cc
+++ b/webrtc/video_engine/vie_capture_impl.cc
@@ -139,13 +139,6 @@
   LOG(LS_INFO) << "Connect capture id " << capture_id
                << " to channel " << video_channel;
 
-  ViEInputManagerScoped is(*(shared_data_->input_manager()));
-  ViECapturer* vie_capture = is.Capture(capture_id);
-  if (!vie_capture) {
-    shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
-    return -1;
-  }
-
   ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
   ViEEncoder* vie_encoder = cs.Encoder(video_channel);
   if (!vie_encoder) {
@@ -158,6 +151,13 @@
     shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId);
     return -1;
   }
+
+  ViEInputManagerScoped is(*(shared_data_->input_manager()));
+  ViECapturer* vie_capture = is.Capture(capture_id);
+  if (!vie_capture) {
+    shared_data_->SetLastError(kViECaptureDeviceDoesNotExist);
+    return -1;
+  }
   //  Check if the encoder already has a connected frame provider
   if (is.FrameProvider(vie_encoder) != NULL) {
     LOG(LS_ERROR) << "Channel already connected to capture device.";