Bug 1058944 - Crash in webrtc::ViEInputManager::CreateCaptureDevice r=jesup
☠☠ backed out by c47c04eceb46 ☠ ☠
authorMatthew A. Miller <linuxwolf@outer-planes.net>
Tue, 26 Aug 2014 17:10:42 -0600
changeset 223540 8328bc2054d14f5d46fe72789c5b94fa41c5457d
parent 223539 79d402a259843fcedb312d6dc18d6151c21a3c9d
child 223541 512598b9ecfcd660d770f1942a6adc3787c3b718
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1058944
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1058944 - Crash in webrtc::ViEInputManager::CreateCaptureDevice r=jesup
media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.cc
media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.h
--- a/media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.cc
+++ b/media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.cc
@@ -346,17 +346,17 @@ VideoCaptureModule::DeviceInfo* DesktopC
       pWindowDeviceInfoImpl = NULL;
     }
     return pWindowDeviceInfoImpl;
   }
   return NULL;
 }
 
 const char* DesktopCaptureImpl::CurrentDeviceName() const {
-  return _deviceUniqueId;
+  return _deviceUniqueId.c_str();
 }
 
 int32_t DesktopCaptureImpl::ChangeUniqueId(const int32_t id) {
   _id = id;
   return 0;
 }
 
 int32_t DesktopCaptureImpl::Init(const char* uniqueId,
@@ -395,16 +395,18 @@ int32_t DesktopCaptureImpl::Init(const c
     }
 
     WindowId winId = atoi(uniqueId);
     pWindowCapturer->SelectWindow(winId);
 
     MouseCursorMonitor *pMouseCursorMonitor = MouseCursorMonitor::CreateForWindow(webrtc::DesktopCaptureOptions::CreateDefault(), winId);
     desktop_capturer_cursor_composer_.reset(new DesktopAndCursorComposer(pWindowCapturer, pMouseCursorMonitor));
   }
+  _deviceUniqueId = uniqueId;
+
   return 0;
 }
 
 // returns the number of milliseconds until the module want a worker thread to call Process
 int32_t DesktopCaptureImpl::TimeUntilNextProcess() {
   CriticalSectionScoped cs(&_callBackCs);
 
   int32_t timeToNormalProcess = kProcessInterval
@@ -448,17 +450,17 @@ int32_t DesktopCaptureImpl::Process() {
 
   _lastProcessFrameCount = _incomingFrameTimes[0];
 
   return 0;
 }
 
 DesktopCaptureImpl::DesktopCaptureImpl(const int32_t id)
   : _id(id),
-    _deviceUniqueId(NULL),
+    _deviceUniqueId(""),
     _apiCs(*CriticalSectionWrapper::CreateCriticalSection()),
     _captureDelay(0),
     _requestedCapability(),
     _callBackCs(*CriticalSectionWrapper::CreateCriticalSection()),
     _lastProcessTime(TickTime::Now()),
     _lastFrameRateCallbackTime(TickTime::Now()),
     _frameRateCallBack(false),
     _noPictureAlarmCallBack(false),
@@ -484,18 +486,16 @@ DesktopCaptureImpl::DesktopCaptureImpl(c
 DesktopCaptureImpl::~DesktopCaptureImpl() {
   capturer_thread_.Stop();
   delete &capturer_thread_;
 
   DeRegisterCaptureDataCallback();
   DeRegisterCaptureCallback();
   delete &_callBackCs;
   delete &_apiCs;
-
-  delete[] _deviceUniqueId;
 }
 
 void DesktopCaptureImpl::RegisterCaptureDataCallback(
                                                      VideoCaptureDataCallback& dataCallBack)
 {
   CriticalSectionScoped cs(&_apiCs);
   CriticalSectionScoped cs2(&_callBackCs);
   _dataCallBack = &dataCallBack;
--- a/media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.h
+++ b/media/webrtc/trunk/webrtc/video_engine/desktop_capture_impl.h
@@ -10,16 +10,18 @@
 
 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MAIN_SOURCE_DESKTOP_CAPTURE_IMPL_H_
 #define WEBRTC_MODULES_DESKTOP_CAPTURE_MAIN_SOURCE_DESKTOP_CAPTURE_IMPL_H_
 
 /*
  * video_capture_impl.h
  */
 
+#include <string>
+
 #include "webrtc/common_video/interface/i420_video_frame.h"
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
 #include "webrtc/modules/desktop_capture/screen_capturer.h"
 #include "webrtc/system_wrappers/interface/tick_util.h"
 #include "webrtc/modules/video_capture/video_capture_config.h"
 #include "webrtc/modules/desktop_capture/shared_memory.h"
 #include "webrtc/system_wrappers/interface/thread_wrapper.h"
 #include "webrtc/modules/desktop_capture/mouse_cursor_shape.h"
@@ -213,17 +215,17 @@ public:
 
 protected:
   DesktopCaptureImpl(const int32_t id);
   virtual ~DesktopCaptureImpl();
   int32_t DeliverCapturedFrame(I420VideoFrame& captureFrame,
                                int64_t capture_time);
 
   int32_t _id; // Module ID
-  char* _deviceUniqueId; // current Device unique name;
+  std::string _deviceUniqueId; // current Device unique name;
   CriticalSectionWrapper& _apiCs;
   int32_t _captureDelay; // Current capture delay. May be changed of platform dependent parts.
   VideoCaptureCapability _requestedCapability; // Should be set by platform dependent code in StartCapture.
 
 private:
   void UpdateFrameCount();
   uint32_t CalculateFrameRate(const TickTime& now);