Bug 918372 - Add some debugging assertions for Android WebRTC. r=blassey
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Wed, 25 Sep 2013 08:03:40 +0200
changeset 148636 cd7c48f51a2e9b05bf00500138ecf26ac14d3947
parent 148635 dc2f96ecb2bccd6117d9633bb699f3819239118e
child 148637 f1184809ec393e37aa896365d12f5e4967bf1980
push id25349
push userryanvm@gmail.com
push dateWed, 25 Sep 2013 18:52:12 +0000
treeherdermozilla-central@39f30376058c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs918372
milestone27.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 918372 - Add some debugging assertions for Android WebRTC. r=blassey
media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
--- a/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/video_capture_android.cc
@@ -12,16 +12,17 @@
 
 #include <stdio.h>
 
 #include "critical_section_wrapper.h"
 #include "ref_count.h"
 #include "trace.h"
 
 #include "AndroidJNIWrapper.h"
+#include "mozilla/Assertions.h"
 
 namespace webrtc
 {
 #if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
 // TODO(leozwang) These SetAndroidVM apis will be refactored, thus we only
 // keep and reference java vm.
 int32_t SetCaptureAndroidVM(void* javaVM, void* javaContext) {
   return videocapturemodule::VideoCaptureAndroid::SetAndroidObjects(
@@ -63,16 +64,18 @@ jclass VideoCaptureAndroid::g_javaCmDevI
 jobject VideoCaptureAndroid::g_javaCmDevInfoObject = NULL;
 
 /*
  * Register references to Java Capture class.
  */
 int32_t VideoCaptureAndroid::SetAndroidObjects(void* javaVM,
                                                void* javaContext) {
 
+  MOZ_ASSERT(javaVM != nullptr || g_javaCmDevInfoClass != nullptr);
+
   g_jvm = static_cast<JavaVM*> (javaVM);
 
   if (javaVM) {
     // Already done? Exit early.
     if (g_javaCmClass != NULL
         && g_javaCmDevInfoClass != NULL
         && g_javaCmDevInfoObject != NULL) {
         return 0;
@@ -219,16 +222,18 @@ int32_t VideoCaptureAndroid::AttachAndUs
     if ((res < 0) || !env) {
       WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                    "%s: Could not attach thread to JVM (%d, %p)",
                    __FUNCTION__, res, env);
       return -1;
     }
     attached = true;
   }
+  MOZ_ASSERT(g_javaCmDevInfoClass != nullptr);
+  MOZ_ASSERT(g_javaCmDevInfoObject != nullptr);
   javaCmDevInfoClass = g_javaCmDevInfoClass;
   javaCmDevInfoObject = g_javaCmDevInfoObject;
   return 0;
 
 }
 
 int32_t VideoCaptureAndroid::ReleaseAndroidDeviceInfoObjects(
     bool attached) {