本文整理汇总了C++中ComObjPtr::isCapturableOrHeld方法的典型用法代码示例。如果您正苦于以下问题:C++ ComObjPtr::isCapturableOrHeld方法的具体用法?C++ ComObjPtr::isCapturableOrHeld怎么用?C++ ComObjPtr::isCapturableOrHeld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComObjPtr
的用法示例。
在下文中一共展示了ComObjPtr::isCapturableOrHeld方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deviceAdded
/**
* Performs the required actions when a device has been added.
*
* This means things like running filters and subsequent capturing and
* VM attaching. This may result in IPC and temporary lock abandonment.
*
* @param aDevice The device in question.
* @param aUSBDevice The USB device structure.
*/
void USBProxyService::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice,
SessionMachinesList &llOpenedMachines,
PUSBDEVICE aUSBDevice)
{
/*
* Validate preconditions.
*/
AssertReturnVoid(!isWriteLockOnCurrentThread());
AssertReturnVoid(!aDevice->isWriteLockOnCurrentThread());
AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("aDevice=%p name={%s} state=%s id={%RTuuid}\n",
(HostUSBDevice *)aDevice,
aDevice->getName().c_str(),
aDevice->getStateName(),
aDevice->getId().raw()));
/*
* Run filters on the device.
*/
if (aDevice->isCapturableOrHeld())
{
devLock.release();
HRESULT rc = runAllFiltersOnDevice(aDevice, llOpenedMachines, NULL /* aIgnoreMachine */);
AssertComRC(rc);
}
NOREF(aUSBDevice);
}
示例2: runAllFiltersOnDevice
/**
* Runs all the filters on the specified device.
*
* All filters mean global and active VM, with the exception of those
* belonging to \a aMachine. If a global ignore filter matched or if
* none of the filters matched, the device will be released back to
* the host.
*
* The device calling us here will be in the HeldByProxy, Unused, or
* Capturable state. The caller is aware that locks held might have
* to be abandond because of IPC and that the device might be in
* almost any state upon return.
*
*
* @returns COM status code (only parameter & state checks will fail).
* @param aDevice The USB device to apply filters to.
* @param aIgnoreMachine The machine to ignore filters from (we've just
* detached the device from this machine).
*
* @note The caller is expected to own no locks.
*/
HRESULT USBProxyService::runAllFiltersOnDevice(ComObjPtr<HostUSBDevice> &aDevice,
SessionMachinesList &llOpenedMachines,
SessionMachine *aIgnoreMachine)
{
LogFlowThisFunc(("{%s} ignoring=%p\n", aDevice->getName().c_str(), aIgnoreMachine));
/*
* Verify preconditions.
*/
AssertReturn(!isWriteLockOnCurrentThread(), E_FAIL);
AssertReturn(!aDevice->isWriteLockOnCurrentThread(), E_FAIL);
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
AutoWriteLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
AssertMsgReturn(aDevice->isCapturableOrHeld(), ("{%s} %s\n", aDevice->getName().c_str(), aDevice->getStateName()), E_FAIL);
/*
* Get the lists we'll iterate.
*/
Host::USBDeviceFilterList globalFilters;
mHost->getUSBFilters(&globalFilters);
/*
* Run global filters filters first.
*/
bool fHoldIt = false;
for (Host::USBDeviceFilterList::const_iterator it = globalFilters.begin();
it != globalFilters.end();
++it)
{
AutoWriteLock filterLock(*it COMMA_LOCKVAL_SRC_POS);
const HostUSBDeviceFilter::Data &data = (*it)->getData();
if (aDevice->isMatch(data))
{
USBDeviceFilterAction_T action = USBDeviceFilterAction_Null;
(*it)->COMGETTER(Action)(&action);
if (action == USBDeviceFilterAction_Ignore)
{
/*
* Release the device to the host and we're done.
*/
filterLock.release();
devLock.release();
alock.release();
aDevice->requestReleaseToHost();
return S_OK;
}
if (action == USBDeviceFilterAction_Hold)
{
/*
* A device held by the proxy needs to be subjected
* to the machine filters.
*/
fHoldIt = true;
break;
}
AssertMsgFailed(("action=%d\n", action));
}
}
globalFilters.clear();
/*
* Run the per-machine filters.
*/
for (SessionMachinesList::const_iterator it = llOpenedMachines.begin();
it != llOpenedMachines.end();
++it)
{
ComObjPtr<SessionMachine> pMachine = *it;
/* Skip the machine the device was just detached from. */
if ( aIgnoreMachine
&& pMachine == aIgnoreMachine)
continue;
/* runMachineFilters takes care of checking the machine state. */
devLock.release();
alock.release();
if (runMachineFilters(pMachine, aDevice))
//.........这里部分代码省略.........