usb.patch

diff --git a/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp b/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
index a51bc36..d21c6cb 100644
--- a/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
+++ b/src/app/virtualbox/src/VBox/Devices/USB/USBProxyDevice.cpp
@@ -845,8 +845,10 @@ static DECLCALLBACK(int) usbProxyConstruct(PPDMUSBINS pUsbIns, int iInstance, PC
      */
     if (!fRemote)
         pThis->pOps = &g_USBProxyDeviceHost;
+#if 0
     else
         pThis->pOps = &g_USBProxyDeviceVRDP;
+#endif
 
     pThis->pvInstanceDataR3 = RTMemAllocZ(pThis->pOps->cbBackend);
     if (!pThis->pvInstanceDataR3)
diff --git a/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp b/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
index 4790fcb..d649ad6 100644
--- a/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
+++ b/src/app/virtualbox/src/VBox/Devices/USB/VUSBDevice.cpp
@@ -230,7 +230,14 @@ bool vusbDevDoSelectConfig(PVUSBDEV pDev, PCVUSBDESCCONFIGEX pCfgDesc)
         if (i != VUSB_PIPE_DEFAULT)
         {
             vusbMsgFreeExtraData(pDev->aPipes[i].pCtrl);
+
+            int rc = RTCritSectDelete(&pDev->aPipes[i].CritSectCtrl);
+            AssertRC(rc);
+
             memset(&pDev->aPipes[i], 0, sizeof(pDev->aPipes[i]));
+
+            rc = RTCritSectInit(&pDev->aPipes[i].CritSectCtrl);
+            AssertRC(rc);
         }
     }
     memset(pDev->paIfStates, 0, pCfgDesc->Core.bNumInterfaces * sizeof(pDev->paIfStates[0]));
@@ -1089,8 +1096,10 @@ static DECLCALLBACK(int) vusbDevCancelAllUrbsWorker(PVUSBDEV pDev, bool fDetachi
             PVUSBURB pNext = pUrb->VUsb.pNext;
             Assert(pUrb->VUsb.pDev == pDev);
 
+#if 0
             AssertMsgFailed(("%s: Leaking left over URB! state=%d pDev=%p[%s]\n",
                              pUrb->pszDesc, pUrb->enmState, pDev, pDev->pUsbIns->pszName));
+#endif
             vusbUrbUnlink(pUrb);
             /* Unlink isn't enough, because boundary timer and detaching will try to reap it.
              * It was tested with MSD & iphone attachment to vSMP guest, if
@@ -1134,7 +1143,7 @@ static DECLCALLBACK(int) vusbDevUrbIoThread(RTTHREAD hThread, void *pvUser)
             vusbUrbDoReapAsyncDev(pDev, RT_INDEFINITE_WAIT);
 
         /* Process any URBs waiting to be cancelled first. */
-        int rc = RTReqQueueProcess(pDev->hReqQueueSync, 0); /* Don't wait if there is nothing to do. */
+        int rc = RTReqQueueProcess(pDev->hReqQueueSync, pDev->enmState == VUSB_DEVICE_STATE_RESET ? 5 : 0); /* if in reset state (takes 10ms) sleep a bit - otherwise this thread consumes in this loop a lot of cpu time */
         Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT);
     }
 
diff --git a/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp b/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp
index 3173a36..8105987 100644
--- a/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp
+++ b/src/app/virtualbox/src/VBox/Devices/build/VBoxDD.cpp
@@ -39,6 +39,7 @@ const void *g_apvVBoxDDDependencies[] =
     NULL,
 };
 
+#if 0
 
 /**
  * Register builtin devices.
@@ -329,6 +330,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_
     return VINF_SUCCESS;
 }
 
+#endif /* if 0 */
 
 /**
  * Register builtin USB device.
diff --git a/src/app/virtualbox/src/VBox/Main/include/Matching.h b/src/app/virtualbox/src/VBox/Main/include/Matching.h
index 2f01f69..9b13e37 100644
--- a/src/app/virtualbox/src/VBox/Main/include/Matching.h
+++ b/src/app/virtualbox/src/VBox/Main/include/Matching.h
@@ -291,10 +291,12 @@ public:
         return mValueAny || mValue == aValue;
     }
 
+#if 0
     bool isMatch (const BOOL aValue) const
     {
         return isMatch (bool (aValue == TRUE));
     }
+#endif /* if 0 */
 
 private:
 
diff --git a/src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp b/src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp
index 141bb98..43cedfe 100644
--- a/src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp
+++ b/src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp
@@ -9136,10 +9136,9 @@ HRESULT Console::captureUSBDevices(PUVM pUVM)
          * us back from under its lock (e.g. onUSBDeviceAttach()) which would
          * produce an inter-process dead-lock otherwise. */
         alock.release();
-#if 0
+
         HRESULT hrc = mControl->AutoCaptureUSBDevices();
         ComAssertComRCRetRC(hrc);
-#endif
     }
 
     return S_OK;
diff --git a/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp b/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
index 09b42f5..c179ca6 100644
--- a/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
+++ b/src/app/virtualbox/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
@@ -1037,13 +1037,10 @@ HRESULT USBDeviceFilters::notifyProxy(bool aInsertFilters)
     LogFlowThisFunc(("aInsertFilters=%RTbool\n", aInsertFilters));
 
     AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), false);
+    AssertComRCReturnRC(autoCaller.rc());
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    USBProxyService *pProxySvc = m->pHost->usbProxyService();
-    AssertReturn(pProxySvc, E_FAIL);
-
     DeviceFilterList::const_iterator it = m->llDeviceFilters->begin();
     while (it != m->llDeviceFilters->end())
     {
@@ -1054,6 +1051,9 @@ HRESULT USBDeviceFilters::notifyProxy(bool aInsertFilters)
             && pFilter->getData().mRemote.isMatch(false) /* and if the filter is NOT remote */
            )
         {
+            USBProxyService *pProxySvc = m->pHost->usbProxyService();
+            AssertReturn(pProxySvc, E_FAIL);
+
             if (aInsertFilters)
             {
                 AssertReturn(pFilter->getId() == NULL, E_FAIL);
