Removed TTY spam in gfxVRExternal draft
authorKearwood "Kip" Gilbert <kearwood@kearwood.com>
Tue, 13 Mar 2018 12:18:16 -0700
changeset 767009 4d40011d64f00c984be51325ad569f6323fa0e77
parent 766572 093e9711557cc70e6dfe283dc7d30e1c3d0733b9
push id102474
push userbmo:kgilbert@mozilla.com
push dateTue, 13 Mar 2018 19:19:00 +0000
milestone60.0a1
Removed TTY spam in gfxVRExternal MozReview-Commit-ID: 5PfzIx0rq2r
gfx/vr/gfxVRExternal.cpp
gfx/vr/ipc/VRMessageUtils.h
--- a/gfx/vr/gfxVRExternal.cpp
+++ b/gfx/vr/gfxVRExternal.cpp
@@ -210,89 +210,84 @@ VRSystemManagerExternal::~VRSystemManage
 }
 
 void
 VRSystemManagerExternal::OpenShmem()
 {
   if (mExternalShmem) {
     return;
   }
-  fprintf(stderr, "Opening Shmem...\n");
+
 #if defined(XP_MACOSX)
-  
+
   if (mShmemFD == 0) {
     mShmemFD = shm_open(kShmemName, O_RDWR, S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
   }
   if (mShmemFD <= 0) {
-    fprintf(stderr, "shm_open error: %i\n", errno); // findme! kip! hack!  Need to properly log this...
     mShmemFD = 0;
     return;
   }
 
   struct stat sb;
   fstat(mShmemFD, &sb);
   off_t length = sb.st_size;
   if (length < (off_t)sizeof(VRExternalShmem)) {
-    fprintf(stderr, "shmem size is smaller than sizeof(VRExternalShmem)\n");
+    // TODO - Implement logging
     CloseShmem();
     return;
   }
 
   mExternalShmem = (VRExternalShmem*)mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, mShmemFD, 0);
   if (mExternalShmem == MAP_FAILED) {
-    fprintf(stderr, "mmap failed for VRExternalShmem\n");
+    // TODO - Implement logging
     mExternalShmem = NULL;
     CloseShmem();
     return;
   }
 
 #elif defined(XP_WIN)
 
   if (mShmemFile == NULL) {
     mShmemFile = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, kShmemName);
     if (mShmemFile == NULL) {
-      fprintf(stderr, "Could not open file mapping object (%d).\n",
-              GetLastError());
+      // TODO - Implement logging
       CloseShmem();
       return;
     }
   }
   LARGE_INTEGER length;
   length.QuadPart = sizeof(VRExternalShmem);
   mExternalShmem = (VRExternalShmem*)MapViewOfFile(mShmemFile, // handle to map object
     FILE_MAP_ALL_ACCESS,  // read/write permission
     0,
     0,
     length.QuadPart);
 
   if (mExternalShmem == NULL) {
-    fprintf(stderr, "Could not map view of file (%d).\n",
-            GetLastError());
+    // TODO - Implement logging
     CloseShmem();
     return;
   }
 #endif
-  fprintf(stderr, "Opened Shmem\n");
   CheckForShutdown();
 }
 
 void
 VRSystemManagerExternal::CheckForShutdown()
 {
   if (mExternalShmem) {
     if (mExternalShmem->generationA == -1 && mExternalShmem->generationB == -1) {
       Shutdown();
     }
   }
 }
 
 void
 VRSystemManagerExternal::CloseShmem()
 {
-  fprintf(stderr, "Closing Shmem...\n");
 #if defined(XP_MACOSX)
   
   if (mExternalShmem) {
     munmap((void *)mExternalShmem, sizeof(VRExternalShmem));
     mExternalShmem = NULL;
   }
   if (mShmemFD) {
     close(mShmemFD);
@@ -304,17 +299,16 @@ VRSystemManagerExternal::CloseShmem()
     UnmapViewOfFile((void *)mExternalShmem);
     mExternalShmem = NULL;
   }
   if (mShmemFile) {
     CloseHandle(mShmemFile);
     mShmemFile = NULL;
   }
 #endif
-  fprintf(stderr, "Closed Shmem\n");
 }
 
 /*static*/ already_AddRefed<VRSystemManagerExternal>
 VRSystemManagerExternal::Create()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!gfxPrefs::VREnabled() || !gfxPrefs::VRExternalEnabled()) {
@@ -451,18 +445,17 @@ VRSystemManagerExternal::RemoveControlle
   mControllerCount = 0;
 }
 
 void
 VRSystemManagerExternal::PullState(VRDisplayState* aDisplayState, VRHMDSensorState* aSensorState /* = nullptr */)
 {
   MOZ_ASSERT(mExternalShmem);
   if (mExternalShmem) {
-    // FINDME!!! TODO!! HACK!! KIP!! Add locking here
-    // for non-x86 platforms, such as a spinlock
+    // TODO - Add locking here for non-x86 platforms
     VRExternalShmem tmp;
     memcpy(&tmp, (void *)mExternalShmem, sizeof(VRExternalShmem));
     if (tmp.generationA == tmp.generationB && tmp.generationA != 0 && tmp.generationA != -1) {
       memcpy(aDisplayState, &tmp.state.displayState, sizeof(VRDisplayState));
       if (aSensorState) {
         memcpy(aSensorState, &tmp.state.sensorState, sizeof(VRHMDSensorState));
       }
     }
--- a/gfx/vr/ipc/VRMessageUtils.h
+++ b/gfx/vr/ipc/VRMessageUtils.h
@@ -33,17 +33,17 @@ struct ParamTraits<mozilla::gfx::VRDispl
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     // TODO - VRDisplayState is asserted to be a POD type
     //        A simple memcpy may be sufficient here, or
     //        this code can be refactored out if we use
     //        shmem between the VR and content process.
     nsCString displayName;
-    displayName.Assign(aParam.mDisplayName); // FINDME!! HACK! - Bounds checking?
+    displayName.Assign(aParam.mDisplayName);
     WriteParam(aMsg, displayName);
     WriteParam(aMsg, aParam.mCapabilityFlags);
     WriteParam(aMsg, aParam.mEyeResolution.width);
     WriteParam(aMsg, aParam.mEyeResolution.height);
     WriteParam(aMsg, aParam.mIsConnected);
     WriteParam(aMsg, aParam.mIsMounted);
     WriteParam(aMsg, aParam.mStageSize.width);
     WriteParam(aMsg, aParam.mStageSize.height);
@@ -74,17 +74,17 @@ struct ParamTraits<mozilla::gfx::VRDispl
         !ReadParam(aMsg, aIter, &(aResult->mStageSize.height))) {
       return false;
     }
     for (int i = 0; i < 16; i++) {
       if (!ReadParam(aMsg, aIter, &(aResult->mSittingToStandingTransform[i]))) {
         return false;
       }
     }
-    strncpy(aResult->mDisplayName, displayName.BeginReading(), mozilla::gfx::kVRDisplayNameMaxLen); // FINDME! TODO! HACK!  Safe? Better way?
+    strncpy(aResult->mDisplayName, displayName.BeginReading(), mozilla::gfx::kVRDisplayNameMaxLen);
     for (int i = 0; i < mozilla::gfx::VRDisplayState::NumEyes; i++) {
       if (!ReadParam(aMsg, aIter, &(aResult->mEyeFOV[i])) ||
           !ReadParam(aMsg, aIter, &(aResult->mEyeTranslation[i].x)) ||
           !ReadParam(aMsg, aIter, &(aResult->mEyeTranslation[i].y)) ||
           !ReadParam(aMsg, aIter, &(aResult->mEyeTranslation[i].z))) {
         return false;
       }
     }