Changeset 8547 in vbox
- Timestamp:
- May 3, 2008 12:54:40 AM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r8544 r8547 2011 2011 Guid (aId).raw()); 2012 2012 2013 # if defined(RT_OS_DARWIN) || defined(NEW_HOSTUSBDEVICE_STATE)2014 2013 /* 2015 2014 * Inform the USB device and USB proxy about what's cooking. … … 2020 2019 return rc2; 2021 2020 alock.enter(); 2022 # ifndef NEW_HOSTUSBDEVICE_STATE2023 for (it = mUSBDevices.begin(); it != mUSBDevices.end(); ++ it)2024 if ((*it)->id() == aId)2025 break;2026 if (it == mUSBDevices.end())2027 return S_OK;2028 # endif2029 # endif2030 2021 2031 2022 /* Request the PDM to detach the USB device. */ -
trunk/src/VBox/Main/HostImpl.cpp
r8484 r8547 1349 1349 AutoWriteLock devLock (device); 1350 1350 1351 #ifdef NEW_HOSTUSBDEVICE_STATE1352 1351 /* 1353 1352 * Work the state machine. … … 1369 1368 } 1370 1369 return hrc; 1371 1372 #else /* !NEW_HOSTUSBDEVICE_STATE */1373 1374 LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d aDone=%RTbool\n",1375 device->id().raw(), device->state(), device->isStatePending(),1376 device->pendingState(), aDone));1377 HRESULT rc = S_OK;1378 if (!aDone)1379 {1380 if (device->isStatePending())1381 rc = setError (E_INVALIDARG,1382 tr ("USB device '%s' with UUID {%Vuuid} is busy (waiting for a pending "1383 "state change). Please try later"),1384 device->name().raw(), device->id().raw());1385 else1386 mUSBProxyService->detachingDevice (device);1387 }1388 else1389 {1390 if (device->isStatePending())1391 {1392 /* If an async detach operation is still pending (darwin), postpone1393 the setHeld() + the re-applying of filters until it is completed.1394 We indicate this by moving to the '*Filters' state variant. */1395 if (device->pendingStateEx() == HostUSBDevice::kDetachingPendingAttach)1396 device->setLogicalReconnect (HostUSBDevice::kDetachingPendingAttachFilters);1397 else if (device->pendingStateEx() == HostUSBDevice::kDetachingPendingDetach)1398 device->setLogicalReconnect (HostUSBDevice::kDetachingPendingDetachFilters);1399 else1400 {1401 Assert (device->pendingStateEx() == HostUSBDevice::kNothingPending);1402 rc = setError (E_INVALIDARG,1403 tr ("USB device '%s' with UUID {%Vuuid} is busy (waiting for a pending "1404 "state change). Please try later"),1405 device->name().raw(), device->id().raw());1406 }1407 }1408 else1409 {1410 ComAssertRet (device->machine() == aMachine, E_FAIL);1411 1412 /* re-apply filters on the device before giving it back to the host */1413 device->setHeld();1414 rc = applyAllUSBFilters (device, aMachine);1415 ComAssertComRC (rc);1416 }1417 }1418 return rc;1419 #endif /* !NEW_HOSTUSBDEVICE_STATE */1420 1370 } 1421 1371 … … 1447 1397 ComObjPtr <HostUSBDevice> device = *it; 1448 1398 AutoWriteLock devLock (device); 1449 #ifdef NEW_HOSTUSBDEVICE_STATE1450 1399 if ( device->unistate() == kHostUSBDeviceState_HeldByProxy 1451 1400 || device->unistate() == kHostUSBDeviceState_Unused 1452 1401 || device->unistate() == kHostUSBDeviceState_Capturable) 1453 1402 applyMachineUSBFilters(aMachine, device); 1454 #else /* !NEW_HOSTUSBDEVICE_STATE */1455 1456 /* skip pending devices */1457 if (device->isStatePending())1458 continue;1459 1460 if (device->state() == USBDeviceState_Busy ||1461 device->state() == USBDeviceState_Available ||1462 device->state() == USBDeviceState_Held)1463 {1464 applyMachineUSBFilters (aMachine, device);1465 }1466 #endif /* !NEW_HOSTUSBDEVICE_STATE */1467 1403 } 1468 1404 … … 1495 1431 if (device->machine() == aMachine) 1496 1432 { 1497 # ifdef NEW_HOSTUSBDEVICE_STATE1498 1433 /* 1499 1434 * Same procedure as in detachUSBDevice(). … … 1508 1443 ComAssertComRC(hrc2); 1509 1444 } 1510 # else /* !NEW_HOSTUSBDEVICE_STATE */1511 if (!aDone)1512 {1513 if (!device->isStatePending())1514 mUSBProxyService->detachingDevice (device);1515 }1516 else1517 {1518 if (!device->isStatePending())1519 {1520 Assert (device->state() == USBDeviceState_Captured);1521 1522 /* re-apply filters on the device before giving it back to the1523 * host */1524 device->setHeld();1525 HRESULT rc = applyAllUSBFilters (device, aMachine);1526 AssertComRC (rc);1527 }1528 else if (device->pendingStateEx() == HostUSBDevice::kNothingPending)1529 device->cancelPendingState();1530 }1531 # endif /* !NEW_HOSTUSBDEVICE_STATE */1532 1445 } 1533 1446 ++ it; … … 2048 1961 AssertReturn(isWriteLockOnCurrentThread(), E_FAIL); 2049 1962 AssertReturn(aDevice->isWriteLockOnCurrentThread(), E_FAIL); 2050 #ifdef NEW_HOSTUSBDEVICE_STATE2051 1963 /* Quietly ignore unsupported and unavailable device. */ 2052 1964 if ( aDevice->unistate() == kHostUSBDeviceState_UsedByHost … … 2056 1968 return S_OK; 2057 1969 } 2058 2059 #else /* !NEW_HOSTUSBDEVICE_STATE */2060 AssertReturn(aDevice->state() != USBDeviceState_Captured, E_FAIL);2061 2062 AssertReturn(aDevice->isStatePending() == false, E_FAIL);2063 2064 /* ignore unsupported devices */2065 if (aDevice->state() == USBDeviceState_NotSupported)2066 return S_OK;2067 /* ignore unavailable devices as well */2068 if (aDevice->state() == USBDeviceState_Unavailable)2069 return S_OK;2070 #endif /* !NEW_HOSTUSBDEVICE_STATE */2071 1970 2072 1971 VirtualBox::SessionMachineVector machines; … … 2157 2056 AssertReturn(isWriteLockOnCurrentThread(), false); 2158 2057 AssertReturn(aDevice->isWriteLockOnCurrentThread(), false); 2159 #ifdef NEW_HOSTUSBDEVICE_STATE2160 2058 /* Let HostUSBDevice::requestCaptureToVM() validate the state. */ 2161 #else /* !NEW_HOSTUSBDEVICE_STATE */2162 AssertReturn (aDevice->state() != USBDeviceState_NotSupported, false);2163 AssertReturn (aDevice->state() != USBDeviceState_Unavailable, false);2164 AssertReturn (aDevice->isStatePending() == false, false);2165 #endif /* !NEW_HOSTUSBDEVICE_STATE */2166 2059 2167 2060 ULONG maskedIfs; … … 2192 2085 AssertReturnVoid(isWriteLockOnCurrentThread()); 2193 2086 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2194 #ifdef NEW_HOSTUSBDEVICE_STATE2195 2087 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2196 2088 aDevice, aDevice->name().raw(), aDevice->stateName(), aDevice->id().raw())); 2197 #else2198 LogFlowThisFunc (("aDevice=%p id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n",2199 aDevice, aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(),2200 aDevice->pendingState()));2201 Assert (aDevice->isStatePending() == false);2202 #endif2203 2089 2204 2090 /* add to the collecion */ … … 2225 2111 AssertReturnVoid(isWriteLockOnCurrentThread()); 2226 2112 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2227 #ifdef NEW_HOSTUSBDEVICE_STATE2228 2113 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2229 2114 aDevice, aDevice->name().raw(), aDevice->stateName(), aDevice->id().raw())); 2230 #else2231 LogFlowThisFunc (("aDevice=%p id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n",2232 aDevice, aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(),2233 aDevice->pendingState()));2234 #endif2235 2115 2236 2116 /* … … 2270 2150 * @param aIgnoreMachine The machine to ignore when running filters. 2271 2151 */ 2272 #ifdef NEW_HOSTUSBDEVICE_STATE2273 2152 void Host::onUSBDeviceStateChanged (HostUSBDevice *aDevice, bool aRunFilters, SessionMachine *aIgnoreMachine) 2274 #else2275 void Host::onUSBDeviceStateChanged (HostUSBDevice *aDevice)2276 #endif2277 2153 { 2278 2154 /* … … 2283 2159 AssertReturnVoid(isWriteLockOnCurrentThread()); 2284 2160 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2285 #ifdef NEW_HOSTUSBDEVICE_STATE2286 2161 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2287 2162 aDevice, aDevice->name().raw(), aDevice->stateName(), aDevice->id().raw())); 2288 #else 2289 LogFlowThisFunc (("aDevice=%p id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2290 aDevice, aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2291 aDevice->pendingState())); 2292 #endif 2293 2294 # ifdef NEW_HOSTUSBDEVICE_STATE 2163 2295 2164 /* 2296 2165 * Run filters if requested to do so. … … 2302 2171 AssertComRC(rc); 2303 2172 } 2304 # else /* !NEW_HOSTUSBDEVICE_STATE */2305 ComObjPtr <HostUSBDevice> device (aDevice);2306 if (device->isStatePending())2307 {2308 /* it was a state change request */2309 if (device->pendingStateEx() == HostUSBDevice::kDetachingPendingAttachFilters)2310 {2311 /* The device has completed an asynchronous detach operation, subject2312 it to the filters and such if the current state permits this.2313 (handlePendingStateChange will disassociate itself from the machine.) */2314 ComObjPtr <SessionMachine> machine (device->machine());2315 device->handlePendingStateChange();2316 if (device->state() == USBDeviceState_Captured)2317 {2318 Log (("USB: running filters on async detached device\n"));2319 device->setHeld();2320 HRESULT rc = applyAllUSBFilters (device, machine);2321 AssertComRC (rc);2322 }2323 else2324 Log (("USB: async detached devices reappeared in stated %d instead of %d!\n",2325 device->state(), USBDeviceState_Captured));2326 }2327 else2328 device->handlePendingStateChange();2329 }2330 else if ( device->state() == USBDeviceState_Available2331 || device->state() == USBDeviceState_Busy)2332 {2333 /* The device has gone from being unavailable (not subject to filters) to being2334 available / busy. This transition can be triggered by udevd or manual2335 permission changes on Linux. On all systems may be triggered by the host2336 ceasing to use the device - like unmounting an MSD in the Finder or invoking2337 the "Safely remove XXXX" stuff on Windows (perhaps). */2338 HRESULT rc = applyAllUSBFilters (device);2339 AssertComRC (rc);2340 }2341 else2342 {2343 /* some external state change */2344 2345 /// @todo re-run all USB filters probably2346 AssertFailed();2347 }2348 # endif /* !NEW_HOSTUSBDEVICE_STATE */2349 2173 } 2350 2174 #endif /* VBOX_WITH_USB */ -
trunk/src/VBox/Main/Makefile.kmk
r8546 r8547 47 47 endif 48 48 VBOX_MAIN_DEFS += VBOX_WITH_UNIXY_TAP_NETWORKING 49 endif50 if1of ($(BUILD_TARGET), darwin linux win) # this is only temporary, all targets will use this soon.51 VBOX_MAIN_DEFS += NEW_HOSTUSBDEVICE_STATE52 49 endif 53 50 ifneq ($(VBOX_VERSION_MAJOR)$(VBOX_VERSION_MINOR)$(VBOX_VERSION_BUILD),160) -
trunk/src/VBox/Main/include/HostImpl.h
r8484 r8547 121 121 void onUSBDeviceAttached (HostUSBDevice *aDevice); 122 122 void onUSBDeviceDetached (HostUSBDevice *aDevice); 123 #ifdef NEW_HOSTUSBDEVICE_STATE124 123 void onUSBDeviceStateChanged(HostUSBDevice *aDevice, bool aRunFilters, SessionMachine *aIgnoreMachine); 125 #else126 void onUSBDeviceStateChanged(HostUSBDevice *aDevice);127 #endif128 124 129 125 /* must be called from under this object's lock */
Note:
See TracChangeset
for help on using the changeset viewer.