Changeset 8471 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 29, 2008 3:20:44 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 30336
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r8439 r8471 2011 2011 Guid (aId).raw()); 2012 2012 2013 # if def RT_OS_DARWIN2014 /* Notify the USB Proxy that we're about to detach the device. Since2015 * we don't dare do IPC when holding the console lock, so we'll have2016 * to revalidate the device when we get back. */2013 # if defined(RT_OS_DARWIN) || defined(NEW_HOSTUSBDEVICE_STATE) 2014 /* 2015 * Inform the USB device and USB proxy about what's cooking. 2016 */ 2017 2017 alock.leave(); 2018 2018 HRESULT rc2 = mControl->DetachUSBDevice (aId, false /* aDone */); … … 2020 2020 return rc2; 2021 2021 alock.enter(); 2022 2022 # ifndef NEW_HOSTUSBDEVICE_STATE 2023 2023 for (it = mUSBDevices.begin(); it != mUSBDevices.end(); ++ it) 2024 2024 if ((*it)->id() == aId) … … 2026 2026 if (it == mUSBDevices.end()) 2027 2027 return S_OK; 2028 # endif 2028 2029 # endif 2029 2030 2030 /* First, request VMM to detach the device*/2031 /* Request the PDM to detach the USB device. */ 2031 2032 HRESULT rc = detachUSBDevice (it); 2032 2033 -
trunk/src/VBox/Main/HostImpl.cpp
r8438 r8471 1349 1349 AutoWriteLock devLock (device); 1350 1350 1351 #ifdef NEW_HOSTUSBDEVICE_STATE 1352 /* 1353 * Work the state machine. 1354 */ 1355 LogFlowThisFunc(("id={%Vuuid} state=%s aDone=%RTbool name={%s}\n", 1356 device->id().raw(), device->stateName(), aDone, device->name().raw())); 1357 bool fRunFilters = false; 1358 HRESULT hrc = device->onDetachFromVM(aMachine, aDone, &fRunFilters); 1359 1360 /* 1361 * Run filters if necessary. 1362 */ 1363 if ( SUCCEEDED(hrc) 1364 && fRunFilters) 1365 { 1366 Assert(aDone && device->unistate() == kHostUSBDeviceState_HeldByProxy && device->machine().isNull()); 1367 HRESULT hrc2 = applyAllUSBFilters(device, aMachine); 1368 ComAssertComRC(hrc2); 1369 } 1370 return hrc; 1371 1372 #else /* !NEW_HOSTUSBDEVICE_STATE */ 1373 1351 1374 LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d aDone=%RTbool\n", 1352 1375 device->id().raw(), device->state(), device->isStatePending(), … … 1393 1416 } 1394 1417 } 1395 1396 1418 return rc; 1419 #endif /* !NEW_HOSTUSBDEVICE_STATE */ 1397 1420 } 1398 1421 … … 1423 1446 { 1424 1447 ComObjPtr <HostUSBDevice> device = *it; 1425 1426 1448 AutoWriteLock devLock (device); 1449 #ifdef NEW_HOSTUSBDEVICE_STATE 1450 if ( device->unistate() == kHostUSBDeviceState_HeldByProxy 1451 || device->unistate() == kHostUSBDeviceState_Unused 1452 || device->unistate() == kHostUSBDeviceState_Capturable) 1453 applyMachineUSBFilters(aMachine, device); 1454 #else /* !NEW_HOSTUSBDEVICE_STATE */ 1427 1455 1428 1456 /* skip pending devices */ … … 1436 1464 applyMachineUSBFilters (aMachine, device); 1437 1465 } 1466 #endif /* !NEW_HOSTUSBDEVICE_STATE */ 1438 1467 } 1439 1468 … … 1466 1495 if (device->machine() == aMachine) 1467 1496 { 1497 # ifdef NEW_HOSTUSBDEVICE_STATE 1498 /* 1499 * Same procedure as in detachUSBDevice(). 1500 */ 1501 bool fRunFilters = false; 1502 HRESULT hrc = device->onDetachFromVM(aMachine, aDone, &fRunFilters); 1503 if ( SUCCEEDED(hrc) 1504 && fRunFilters) 1505 { 1506 Assert(aDone && device->unistate() == kHostUSBDeviceState_HeldByProxy && device->machine().isNull()); 1507 HRESULT hrc2 = applyAllUSBFilters(device, aMachine); 1508 ComAssertComRC(hrc2); 1509 } 1510 # else /* !NEW_HOSTUSBDEVICE_STATE */ 1468 1511 if (!aDone) 1469 1512 { … … 1486 1529 device->cancelPendingState(); 1487 1530 } 1531 # endif /* !NEW_HOSTUSBDEVICE_STATE */ 1488 1532 } 1489 1533 ++ it; … … 1996 2040 SessionMachine *aMachine /* = NULL */) 1997 2041 { 1998 LogFlowThisFunc (("\n")); 1999 2042 LogFlowThisFunc(("{%s}\n", aDevice->name().raw())); 2043 2044 /* 2045 * Verify preconditions. 2046 */ 2000 2047 /// @todo must check for read lock, it's enough here 2001 AssertReturn (isWriteLockOnCurrentThread(), E_FAIL); 2002 2003 AssertReturn (aDevice->isWriteLockOnCurrentThread(), E_FAIL); 2004 2005 AssertReturn (aDevice->state() != USBDeviceState_Captured, E_FAIL); 2006 2007 AssertReturn (aDevice->isStatePending() == false, E_FAIL); 2048 AssertReturn(isWriteLockOnCurrentThread(), E_FAIL); 2049 AssertReturn(aDevice->isWriteLockOnCurrentThread(), E_FAIL); 2050 #ifdef NEW_HOSTUSBDEVICE_STATE 2051 /* Quietly ignore unsupported and unavailable device. */ 2052 if ( aDevice->unistate() == kHostUSBDeviceState_UsedByHost 2053 || aDevice->unistate() == kHostUSBDeviceState_Unsupported) /** @todo !aDevice->isCapturable() or something */ 2054 { 2055 LogFlowThisFunc(("{%s} %s - quietly ignored\n", aDevice->name().raw(), aDevice->stateName())); 2056 return S_OK; 2057 } 2058 2059 #else /* !NEW_HOSTUSBDEVICE_STATE */ 2060 AssertReturn(aDevice->state() != USBDeviceState_Captured, E_FAIL); 2061 2062 AssertReturn(aDevice->isStatePending() == false, E_FAIL); 2008 2063 2009 2064 /* ignore unsupported devices */ … … 2013 2068 if (aDevice->state() == USBDeviceState_Unavailable) 2014 2069 return S_OK; 2070 #endif /* !NEW_HOSTUSBDEVICE_STATE */ 2015 2071 2016 2072 VirtualBox::SessionMachineVector machines; … … 2092 2148 ComObjPtr <HostUSBDevice> &aDevice) 2093 2149 { 2094 LogFlowThisFunc (("\n")); 2095 2096 AssertReturn (aMachine, false); 2097 2150 LogFlowThisFunc(("{%s}\n", aDevice->name().raw())); 2151 2152 /* 2153 * Validate preconditions. 2154 */ 2155 AssertReturn(aMachine, false); 2098 2156 /// @todo must check for read lock, it's enough here 2099 AssertReturn (isWriteLockOnCurrentThread(), false); 2100 2101 AssertReturn (aDevice->isWriteLockOnCurrentThread(), false); 2102 2157 AssertReturn(isWriteLockOnCurrentThread(), false); 2158 AssertReturn(aDevice->isWriteLockOnCurrentThread(), false); 2159 #ifdef NEW_HOSTUSBDEVICE_STATE 2160 /* Let HostUSBDevice::requestCaptureToVM() validate the state. */ 2161 #else /* !NEW_HOSTUSBDEVICE_STATE */ 2103 2162 AssertReturn (aDevice->state() != USBDeviceState_NotSupported, false); 2104 2163 AssertReturn (aDevice->state() != USBDeviceState_Unavailable, false); 2105 2106 2164 AssertReturn (aDevice->isStatePending() == false, false); 2165 #endif /* !NEW_HOSTUSBDEVICE_STATE */ 2107 2166 2108 2167 ULONG maskedIfs; 2109 2168 bool hasMatch = aMachine->hasMatchingUSBFilter (aDevice, &maskedIfs); 2110 2111 2169 if (hasMatch) 2112 2170 { … … 2128 2186 void Host::onUSBDeviceAttached (HostUSBDevice *aDevice) 2129 2187 { 2130 LogFlowThisFunc (("aDevice=%p\n", aDevice)); 2131 2132 AssertReturnVoid (aDevice); 2133 2134 AssertReturnVoid (isWriteLockOnCurrentThread()); 2135 AssertReturnVoid (aDevice->isWriteLockOnCurrentThread()); 2136 2137 LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2138 aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2188 /* 2189 * Validate precoditions. 2190 */ 2191 AssertReturnVoid(aDevice); 2192 AssertReturnVoid(isWriteLockOnCurrentThread()); 2193 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2194 #ifdef NEW_HOSTUSBDEVICE_STATE 2195 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2196 aDevice, aDevice->name().raw(), aDevice->stateName(), aDevice->id().raw())); 2197 #else 2198 LogFlowThisFunc (("aDevice=%p id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2199 aDevice, aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2139 2200 aDevice->pendingState())); 2140 2141 2201 Assert (aDevice->isStatePending() == false); 2202 #endif 2142 2203 2143 2204 /* add to the collecion */ … … 2158 2219 void Host::onUSBDeviceDetached (HostUSBDevice *aDevice) 2159 2220 { 2160 LogFlowThisFunc (("aDevice=%p\n", aDevice)); 2161 2162 AssertReturnVoid (aDevice); 2163 2164 AssertReturnVoid (isWriteLockOnCurrentThread()); 2165 AssertReturnVoid (aDevice->isWriteLockOnCurrentThread()); 2166 2167 LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2168 aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2221 /* 2222 * Validate preconditions. 2223 */ 2224 AssertReturnVoid(aDevice); 2225 AssertReturnVoid(isWriteLockOnCurrentThread()); 2226 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2227 #ifdef NEW_HOSTUSBDEVICE_STATE 2228 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2229 aDevice, aDevice->name().raw(), aDevice->stateName(), aDevice->id().raw())); 2230 #else 2231 LogFlowThisFunc (("aDevice=%p id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2232 aDevice, aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2169 2233 aDevice->pendingState())); 2170 2234 #endif 2235 2236 /* 2237 * Remove from the list. 2238 */ 2171 2239 Guid id = aDevice->id(); 2172 2240 … … 2198 2266 * interaction. 2199 2267 * 2200 * @param aDevice The device in question. 2268 * @param aDevice The device in question. 2269 * @param aRunFilters Whether to run filters. 2270 * @param aIgnoreMachine The machine to ignore when running filters. 2201 2271 */ 2272 #ifdef NEW_HOSTUSBDEVICE_STATE 2273 void Host::onUSBDeviceStateChanged (HostUSBDevice *aDevice, bool aRunFilters, SessionMachine *aIgnoreMachine) 2274 #else 2202 2275 void Host::onUSBDeviceStateChanged (HostUSBDevice *aDevice) 2203 { 2204 LogFlowThisFunc (("aDevice=%p\n", aDevice)); 2205 2206 AssertReturnVoid (aDevice); 2207 2208 AssertReturnVoid (isWriteLockOnCurrentThread()); 2209 AssertReturnVoid (aDevice->isWriteLockOnCurrentThread()); 2210 2211 LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d\n", 2212 aDevice->id().raw(), aDevice->state(), aDevice->isStatePending(), 2276 #endif 2277 { 2278 /* 2279 * Validate preconditions. 2280 */ 2281 LogFlowThisFunc(("aDevice=%p\n", aDevice)); 2282 AssertReturnVoid(aDevice); 2283 AssertReturnVoid(isWriteLockOnCurrentThread()); 2284 AssertReturnVoid(aDevice->isWriteLockOnCurrentThread()); 2285 #ifdef NEW_HOSTUSBDEVICE_STATE 2286 LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n", 2287 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(), 2213 2291 aDevice->pendingState())); 2214 2215 2292 #endif 2293 2294 # ifdef NEW_HOSTUSBDEVICE_STATE 2295 /* 2296 * Run filters if requested to do so. 2297 */ 2298 if (aRunFilters) 2299 { 2300 ComObjPtr<HostUSBDevice> device(aDevice); 2301 HRESULT rc = applyAllUSBFilters(device, aIgnoreMachine); 2302 AssertComRC(rc); 2303 } 2304 # else /* !NEW_HOSTUSBDEVICE_STATE */ 2216 2305 ComObjPtr <HostUSBDevice> device (aDevice); 2217 2306 if (device->isStatePending()) … … 2257 2346 AssertFailed(); 2258 2347 } 2348 # endif /* !NEW_HOSTUSBDEVICE_STATE */ 2259 2349 } 2260 2350 #endif /* VBOX_WITH_USB */ -
trunk/src/VBox/Main/include/HostImpl.h
r8401 r8471 121 121 void onUSBDeviceAttached (HostUSBDevice *aDevice); 122 122 void onUSBDeviceDetached (HostUSBDevice *aDevice); 123 void onUSBDeviceStateChanged (HostUSBDevice *aDevice); 123 #ifdef NEW_HOSTUSBDEVICE_STATE 124 void onUSBDeviceStateChanged(HostUSBDevice *aDevice, bool aRunFilters, SessionMachine *aIgnoreMachine); 125 #else 126 void onUSBDeviceStateChanged(HostUSBDevice *aDevice); 127 #endif 124 128 125 129 /* must be called from under this object's lock */ … … 183 187 #ifdef VBOX_WITH_USB 184 188 typedef std::list <ComObjPtr <HostUSBDevice> > USBDeviceList; 185 USBDeviceList mUSBDevices; 189 USBDeviceList mUSBDevices; /**< @todo remove this, use the one maintained by USBProxyService. */ 186 190 187 191 typedef std::list <ComObjPtr <HostUSBDeviceFilter> > USBDeviceFilterList;
Note:
See TracChangeset
for help on using the changeset viewer.