Reduce the scope of rtc::Event::Wait() locking.

Reduces contention on event_mutex_ while taking gettimeofday(). Impact
highly hypothetical at this point, but less locking is better.

BUG=
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1716563003 .

Cr-Original-Commit-Position: refs/heads/master@{#11706}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 7ddc9deb4d7fd6c5396ba55a0ba0e24bf5ef920e
diff --git a/base/event.cc b/base/event.cc
index a9af208..0e267dc 100644
--- a/base/event.cc
+++ b/base/event.cc
@@ -79,14 +79,13 @@
 }
 
 bool Event::Wait(int milliseconds) {
-  pthread_mutex_lock(&event_mutex_);
   int error = 0;
 
+  struct timespec ts;
   if (milliseconds != kForever) {
     // Converting from seconds and microseconds (1e-6) plus
     // milliseconds (1e-3) to seconds and nanoseconds (1e-9).
 
-    struct timespec ts;
 #if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
     // Use relative time version, which tends to be more efficient for
     // pthread implementations where provided (like on Android).
@@ -105,7 +104,10 @@
       ts.tv_nsec -= 1000000000;
     }
 #endif
+  }
 
+  pthread_mutex_lock(&event_mutex_);
+  if (milliseconds != kForever) {
     while (!event_status_ && error == 0) {
 #if HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
       error = pthread_cond_timedwait_relative_np(