VirtualBox

Changeset 2939 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 30, 2007 4:59:36 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21620
Message:

Main: Preparations for async USB handling.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostImpl.cpp

    r2929 r2939  
    12281228            id.toString().raw());
    12291229
     1230    AutoLock devLock (device);
     1231
    12301232    if (device->state() == USBDeviceState_USBDeviceNotSupported)
    12311233        return setError (E_INVALIDARG,
     
    12741276HRESULT Host::releaseUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId)
    12751277{
     1278    LogFlowThisFunc (("aMachine=%p, aId={%Vuuid}\n", aMachine, Guid (aId).raw()));
     1279
    12761280    AutoLock lock (this);
    12771281    CHECK_READY();
     
    12871291
    12881292    ComAssertRet (!!device, E_FAIL);
     1293   
     1294    AutoLock devLock (device);
     1295
    12891296    ComAssertRet (device->machine() == aMachine, E_FAIL);
    12901297
    1291     // reset the device and apply filters
     1298    /* reset the device and apply filters */
    12921299    int vrc = device->reset();
    12931300    ComAssertRCRet (vrc, E_FAIL);
     
    13241331    {
    13251332        ComObjPtr <HostUSBDevice> device = *it;
     1333
     1334        AutoLock devLock (device);
     1335
     1336/// @todo remove
     1337#if 0
    13261338        if (device->isIgnored())
    13271339            continue;
     1340#endif
    13281341
    13291342        if (device->state() == USBDeviceState_USBDeviceBusy ||
     
    13731386    {
    13741387        ComObjPtr <HostUSBDevice> device = *it;
     1388
     1389        AutoLock devLock (device);
     1390
    13751391        if (device->machine() == aMachine)
    13761392        {
     
    16491665                                  SessionMachine *aMachine /* = NULL  */)
    16501666{
    1651     LogFlowMember (("Host::applyAllUSBFilters: \n"));
     1667    LogFlowThisFunc (("\n"));
     1668
     1669    AssertReturn (isLockedOnCurrentThread(), E_FAIL);
     1670
     1671    AutoLock devLock (aDevice);
    16521672
    16531673    /* ignore unsupported devices */
     
    16871707        if (aDevice->state() == USBDeviceState_USBDeviceCaptured)
    16881708        {
    1689             // inform the machine's process about the auto-capture
     1709            /* inform the VM process about the auto-capture */
    16901710            ComPtr <IUSBDevice> d;
    16911711            aDevice.queryInterfaceTo (d.asOutParam());
     1712           
     1713            /* the VM process will query the object, so leave the lock */
     1714            devLock.leave();
     1715
    16921716            HRESULT rc = machines [i]->onUSBDeviceAttach (d);
    16931717            if (SUCCEEDED(rc))
    16941718                return rc;
    16951719
    1696             // the machine rejected it, continue applying filters.
     1720            devLock.enter();
     1721
     1722            /* the machine rejected it, continue applying filters. */
    16971723            aDevice->reset();
    16981724        }
     
    17311757    LogFlowThisFunc (("\n"));
    17321758
    1733     AssertReturn (aMachine, (void) 0);
    1734     AssertReturn (aDevice->state() != USBDeviceState_USBDeviceUnavailable, (void) 0);
     1759    AssertReturnVoid (isLockedOnCurrentThread());
     1760    AssertReturnVoid (aDevice->isLockedOnCurrentThread());
     1761
     1762    AssertReturnVoid (aMachine);
     1763    AssertReturnVoid (aDevice->state() != USBDeviceState_USBDeviceUnavailable);
    17351764
    17361765    /* We're going to use aMachine which is not our child/parent, add a caller */
     
    17671796void Host::onUSBDeviceAttached (HostUSBDevice *aDevice)
    17681797{
    1769     LogFlowMember (("Host::onUSBDeviceAttached: aDevice=%p\n", aDevice));
     1798    LogFlowThisFunc (("aDevice=%p\n", aDevice));
     1799
     1800    AssertReturnVoid (aDevice);
     1801
    17701802    /// @todo (dmik) check locks
    17711803    AutoLock alock (this);
    17721804
    1773     // add to the collecion
     1805    AutoLock devLock (aDevice);
     1806
     1807    /* add to the collecion */
    17741808    mUSBDevices.push_back (aDevice);
    17751809
    1776     // apply all filters (no need to lock the device, nobody can access it yet)
    1777     ComObjPtr <HostUSBDevice> DevPtr(aDevice);
    1778     HRESULT rc = applyAllUSBFilters (DevPtr);
     1810    /* apply all filters */
     1811    ComObjPtr <HostUSBDevice> device (aDevice);
     1812    HRESULT rc = applyAllUSBFilters (device);
    17791813    AssertComRC (rc);
    17801814}
     
    17881822void Host::onUSBDeviceDetached (HostUSBDevice *aDevice)
    17891823{
    1790     LogFlowMember (("Host::onUSBDeviceDetached: aDevice=%p\n", aDevice));
     1824    LogFlowThisFunc (("aDevice=%p\n", aDevice));
     1825
     1826    AssertReturnVoid (aDevice);
     1827
    17911828    /// @todo (dmik) check locks
    17921829    AutoLock alock (this);
     1830
     1831    AutoLock devLock (aDevice);
    17931832
    17941833    Guid id = aDevice->id();
     
    18061845    }
    18071846
    1808     AssertReturn (!!device, (void) 0);
    1809 
    1810     // remove from the collecion
     1847    AssertReturnVoid (!!device);
     1848
     1849    /* remove from the collecion */
    18111850    mUSBDevices.erase (it);
    18121851
    18131852    if (device->machine())
    18141853    {
    1815         // the device is captured by a machine, instruct it to release
    1816         alock.unlock();
     1854        /* the device is captured by a machine, instruct it to release */
     1855
     1856        devLock.leave();
     1857        alock.leave();
     1858
    18171859        HRESULT rc = device->machine()->onUSBDeviceDetach (device->id());
    18181860        AssertComRC (rc);
     
    18281870void Host::onUSBDeviceStateChanged (HostUSBDevice *aDevice)
    18291871{
    1830     LogFlowMember (("Host::onUSBDeviceStateChanged: \n"));
     1872    LogFlowThisFunc (("aDevice=%p\n", aDevice));
     1873
    18311874    /// @todo (dmik) check locks
    18321875    AutoLock alock (this);
  • trunk/src/VBox/Main/HostUSBDeviceImpl.cpp

    r2723 r2939  
    2626#include <VBox/err.h>
    2727
    28 
    2928// constructor / destructor
    3029/////////////////////////////////////////////////////////////////////////////
    3130
    32 HostUSBDevice::HostUSBDevice()
    33     : mUSBProxyService (NULL), m_pUsb (NULL)
    34 {
    35 }
    36 
    37 HostUSBDevice::~HostUSBDevice()
    38 {
    39     if (m_pUsb)
    40     {
    41         USBProxyService::freeDevice (m_pUsb);
    42         m_pUsb = NULL;
    43     }
     31DEFINE_EMPTY_CTOR_DTOR (HostUSBDevice)
     32
     33HRESULT HostUSBDevice::FinalConstruct()
     34{
     35    mUSBProxyService = NULL;
     36    mUsb = NULL;
     37
     38    return S_OK;
     39}
     40
     41void HostUSBDevice::FinalRelease()
     42{
     43    uninit();
    4444}
    4545
     
    6060    ComAssertRet (aUsb, E_INVALIDARG);
    6161
    62     AutoLock alock (this);
     62    /* Enclose the state transition NotReady->InInit->Ready */
     63    AutoInitSpan autoInitSpan (this);
     64    AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
    6365
    6466    /*
     
    6668     * The UUID isn't stored anywhere.
    6769     */
    68     mId.create();
     70    unconst (mId).create();
    6971
    7072    /*
     
    98100    }
    99101
    100     /*
    101      * Other data members.
    102      */
     102    mPendingState = mState;
     103
     104    /* Other data members */
     105    mIsStatePending = false;
     106/// @todo remove
     107#if 0
    103108    mIgnored = false;
     109#endif
    104110    mUSBProxyService = aUSBProxyService;
    105     m_pUsb = aUsb;
    106 
    107     setReady (true);
    108     return S_OK;
     111    mUsb = aUsb;
     112
     113    /* Confirm the successful initialization */
     114    autoInitSpan.setSucceeded();
     115
     116    return S_OK;
     117}
     118
     119/**
     120 *  Uninitializes the instance and sets the ready flag to FALSE.
     121 *  Called either from FinalRelease() or by the parent when it gets destroyed.
     122 */
     123void HostUSBDevice::uninit()
     124{
     125    /* Enclose the state transition Ready->InUninit->NotReady */
     126    AutoUninitSpan autoUninitSpan (this);
     127    if (autoUninitSpan.uninitDone())
     128        return;
     129
     130    if (mUsb != NULL)
     131    {
     132        USBProxyService::freeDevice (mUsb);
     133        mUsb = NULL;
     134    }
     135
     136    mUSBProxyService = NULL;
    109137}
    110138
     
    112140/////////////////////////////////////////////////////////////////////////////
    113141
    114 /**
    115  * Returns the GUID.
    116  *
    117  * @returns COM status code
    118  * @param   aId     Address of result variable.
    119  */
    120142STDMETHODIMP HostUSBDevice::COMGETTER(Id)(GUIDPARAMOUT aId)
    121143{
     
    123145        return E_INVALIDARG;
    124146
    125     AutoLock alock (this);
    126     CHECK_READY();
    127 
     147    AutoCaller autoCaller (this);
     148    CheckComRCReturnRC (autoCaller.rc());
     149
     150    /* mId is constant during life time, no need to lock */
    128151    mId.cloneTo (aId);
    129     return S_OK;
    130 }
    131 
    132 
    133 /**
    134  * Returns the vendor Id.
    135  *
    136  * @returns COM status code
    137  * @param   aVendorId   Where to store the vendor id.
    138  */
     152
     153    return S_OK;
     154}
     155
    139156STDMETHODIMP HostUSBDevice::COMGETTER(VendorId)(USHORT *aVendorId)
    140157{
     
    142159        return E_INVALIDARG;
    143160
    144     AutoLock alock (this);
    145     CHECK_READY();
    146 
    147     *aVendorId = m_pUsb->idVendor;
    148     return S_OK;
    149 }
    150 
    151 
    152 /**
    153  * Returns the product Id.
    154  *
    155  * @returns COM status code
    156  * @param   aProductId      Where to store the product id.
    157  */
     161    AutoCaller autoCaller (this);
     162    CheckComRCReturnRC (autoCaller.rc());
     163
     164    AutoReaderLock alock (this);
     165
     166    *aVendorId = mUsb->idVendor;
     167
     168    return S_OK;
     169}
     170
    158171STDMETHODIMP HostUSBDevice::COMGETTER(ProductId)(USHORT *aProductId)
    159172{
     
    161174        return E_INVALIDARG;
    162175
    163     AutoLock alock (this);
    164     CHECK_READY();
    165 
    166     *aProductId = m_pUsb->idProduct;
    167     return S_OK;
    168 }
    169 
    170 
    171 /**
    172  * Returns the revision BCD.
    173  *
    174  * @returns COM status code
    175  * @param   aRevision       Where to store the revision BCD.
    176  */
     176    AutoCaller autoCaller (this);
     177    CheckComRCReturnRC (autoCaller.rc());
     178
     179    AutoReaderLock alock (this);
     180
     181    *aProductId = mUsb->idProduct;
     182
     183    return S_OK;
     184}
     185
    177186STDMETHODIMP HostUSBDevice::COMGETTER(Revision)(USHORT *aRevision)
    178187{
     
    180189        return E_INVALIDARG;
    181190
    182     AutoLock alock (this);
    183     CHECK_READY();
    184 
    185     *aRevision = m_pUsb->bcdDevice;
    186     return S_OK;
    187 }
    188 
    189 /**
    190  * Returns the manufacturer string.
    191  *
    192  * @returns COM status code
    193  * @param   aManufacturer       Where to put the return string.
    194  */
     191    AutoCaller autoCaller (this);
     192    CheckComRCReturnRC (autoCaller.rc());
     193
     194    AutoReaderLock alock (this);
     195
     196    *aRevision = mUsb->bcdDevice;
     197
     198    return S_OK;
     199}
     200
    195201STDMETHODIMP HostUSBDevice::COMGETTER(Manufacturer)(BSTR *aManufacturer)
    196202{
     
    198204        return E_INVALIDARG;
    199205
    200     AutoLock alock (this);
    201     CHECK_READY();
    202 
    203     Bstr (m_pUsb->pszManufacturer).cloneTo (aManufacturer);
    204     return S_OK;
    205 }
    206 
    207 
    208 /**
    209  * Returns the product string.
    210  *
    211  * @returns COM status code
    212  * @param   aProduct            Where to put the return string.
    213  */
     206    AutoCaller autoCaller (this);
     207    CheckComRCReturnRC (autoCaller.rc());
     208
     209    AutoReaderLock alock (this);
     210
     211    Bstr (mUsb->pszManufacturer).cloneTo (aManufacturer);
     212
     213    return S_OK;
     214}
     215
    214216STDMETHODIMP HostUSBDevice::COMGETTER(Product)(BSTR *aProduct)
    215217{
     
    217219        return E_INVALIDARG;
    218220
    219     AutoLock alock (this);
    220     CHECK_READY();
    221 
    222     Bstr (m_pUsb->pszProduct).cloneTo (aProduct);
    223     return S_OK;
    224 }
    225 
    226 
    227 /**
    228  * Returns the serial number string.
    229  *
    230  * @returns COM status code
    231  * @param   aSerialNumber     Where to put the return string.
    232  */
     221    AutoCaller autoCaller (this);
     222    CheckComRCReturnRC (autoCaller.rc());
     223
     224    AutoReaderLock alock (this);
     225
     226    Bstr (mUsb->pszProduct).cloneTo (aProduct);
     227
     228    return S_OK;
     229}
     230
    233231STDMETHODIMP HostUSBDevice::COMGETTER(SerialNumber)(BSTR *aSerialNumber)
    234232{
     
    236234        return E_INVALIDARG;
    237235
    238     AutoLock alock (this);
    239     CHECK_READY();
    240 
    241     Bstr (m_pUsb->pszSerialNumber).cloneTo (aSerialNumber);
    242     return S_OK;
    243 }
    244 
    245 /**
    246  * Returns the device address string.
    247  *
    248  * @returns COM status code
    249  * @param   aAddress            Where to put the returned string.
    250  */
     236    AutoCaller autoCaller (this);
     237    CheckComRCReturnRC (autoCaller.rc());
     238
     239    AutoReaderLock alock (this);
     240
     241    Bstr (mUsb->pszSerialNumber).cloneTo (aSerialNumber);
     242
     243    return S_OK;
     244}
     245
    251246STDMETHODIMP HostUSBDevice::COMGETTER(Address)(BSTR *aAddress)
    252247{
     
    254249        return E_INVALIDARG;
    255250
    256     AutoLock alock (this);
    257     CHECK_READY();
    258 
    259     Bstr (m_pUsb->pszAddress).cloneTo (aAddress);
     251    AutoCaller autoCaller (this);
     252    CheckComRCReturnRC (autoCaller.rc());
     253
     254    AutoReaderLock alock (this);
     255
     256    Bstr (mUsb->pszAddress).cloneTo (aAddress);
     257
    260258    return S_OK;
    261259}
     
    266264        return E_INVALIDARG;
    267265
    268     AutoLock alock (this);
    269     CHECK_READY();
     266    AutoCaller autoCaller (this);
     267    CheckComRCReturnRC (autoCaller.rc());
     268
     269    AutoReaderLock alock (this);
    270270
    271271    ///@todo implement
    272272    aPort = 0;
     273
    273274    return S_OK;
    274275}
     
    279280        return E_INVALIDARG;
    280281
    281     AutoLock alock (this);
    282     CHECK_READY();
     282    AutoCaller autoCaller (this);
     283    CheckComRCReturnRC (autoCaller.rc());
     284
     285    AutoReaderLock alock (this);
    283286
    284287    *aRemote = FALSE;
     288
    285289    return S_OK;
    286290}
     
    294298        return E_POINTER;
    295299
    296     AutoLock lock (this);
    297     CHECK_READY();
     300    AutoCaller autoCaller (this);
     301    CheckComRCReturnRC (autoCaller.rc());
     302
     303    AutoReaderLock alock (this);
    298304
    299305    *aState = mState;
     306
    300307    return S_OK;
    301308}
     
    305312////////////////////////////////////////////////////////////////////////////////
    306313
     314/**
     315 * @note Locks this object for reading.
     316 */
    307317Utf8Str HostUSBDevice::name()
    308318{
    309319    Utf8Str name;
    310320
    311     AutoLock alock (this);
    312     AssertReturn (isReady(), name);
    313 
    314     bool haveManufacturer = m_pUsb->pszManufacturer && *m_pUsb->pszManufacturer;
    315     bool haveProduct = m_pUsb->pszProduct && *m_pUsb->pszProduct;
     321    AutoCaller autoCaller (this);
     322    AssertComRCReturn (autoCaller.rc(), name);
     323
     324    AutoReaderLock alock (this);
     325
     326    bool haveManufacturer = mUsb->pszManufacturer && *mUsb->pszManufacturer;
     327    bool haveProduct = mUsb->pszProduct && *mUsb->pszProduct;
    316328    if (haveManufacturer && haveProduct)
    317         name = Utf8StrFmt ("%s %s", m_pUsb->pszManufacturer,
    318                                      m_pUsb->pszProduct);
     329        name = Utf8StrFmt ("%s %s", mUsb->pszManufacturer,
     330                                     mUsb->pszProduct);
    319331    else if(haveManufacturer)
    320         name = Utf8StrFmt ("%s", m_pUsb->pszManufacturer);
     332        name = Utf8StrFmt ("%s", mUsb->pszManufacturer);
    321333    else if(haveProduct)
    322         name = Utf8StrFmt ("%s", m_pUsb->pszManufacturer);
     334        name = Utf8StrFmt ("%s", mUsb->pszManufacturer);
    323335    else
    324336        name = "<unknown>";
     
    327339}
    328340
    329 /** Sets the ignored flag and returns the device to the host */
     341/// @todo remove
     342#if 0
     343/**
     344 * Sets the ignored flag and returns the device to the host.
     345 *
     346 * @note Locks this object for writing.
     347 */
    330348void HostUSBDevice::setIgnored()
    331349{
     350    AutoCaller autoCaller (this);
     351    AssertComRCReturnVoid (autoCaller.rc());
     352
    332353    AutoLock alock (this);
    333     AssertReturn (isReady(), (void) 0);
    334 
    335     AssertReturn (!mIgnored, (void) 0);
    336 
    337     mIgnored = false;
     354
     355    AssertReturnVoid (!mIgnored);
     356
     357    mIgnored = true;
     358
    338359    setHostDriven();
    339360}
    340 
    341 /** Requests the capture */
     361#endif
     362
     363/**
     364 * @note Locks this object for writing.
     365 */
    342366bool HostUSBDevice::setCaptured (SessionMachine *aMachine)
    343367{
    344368    AssertReturn (aMachine, false);
    345369
     370    AutoCaller autoCaller (this);
     371    AssertComRCReturn (autoCaller.rc(), false);
     372
    346373    AutoLock alock (this);
    347     AssertReturn (isReady(), false);
    348374
    349375    AssertReturn (
     
    353379        false);
    354380
    355     mUSBProxyService->captureDevice (this);
    356 
    357381    mState = USBDeviceState_USBDeviceCaptured;
    358382    mMachine = aMachine;
    359383
     384    mUSBProxyService->captureDevice (this);
     385
    360386    return true;
    361387}
     
    365391 *
    366392 * @returns VBox status code.
     393 *
     394 * @note Locks this object for writing.
    367395 */
    368396int HostUSBDevice::setHostDriven()
    369397{
     398    AutoCaller autoCaller (this);
     399    AssertComRCReturn (autoCaller.rc(), VERR_INVALID_PARAMETER);
     400
    370401    AutoLock alock (this);
    371     AssertReturn (isReady(), VERR_INVALID_PARAMETER);
    372402
    373403    AssertReturn (mState == USBDeviceState_USBDeviceHeld, VERR_INVALID_PARAMETER);
     
    382412 *
    383413 * @returns VBox status code.
     414 *
     415 * @note Locks this object for writing.
    384416 */
    385417int HostUSBDevice::reset()
    386418{
     419    AutoCaller autoCaller (this);
     420    AssertComRCReturn (autoCaller.rc(), VERR_INVALID_PARAMETER);
     421
    387422    AutoLock alock (this);
    388     AssertReturn (isReady(), VERR_INVALID_PARAMETER);
    389423
    390424    mState = USBDeviceState_USBDeviceHeld;
    391425    mMachine.setNull();
     426/// @todo remove
     427#if 0
    392428    mIgnored = false;
     429#endif
    393430
    394431    /** @todo this operation might fail and cause the device to the reattached with a different address and all that. */
     
    396433}
    397434
     435/// @todo remove
     436#if 0
    398437/**
    399438 *  Sets the state of the device, as it was reported by the host.
     
    401440 *
    402441 *  @param  aState      new state
     442 *
     443 *  @note Locks this object for writing.
    403444 */
    404445void HostUSBDevice::setHostState (USBDeviceState_T aState)
    405446{
     447    AutoCaller autoCaller (this);
     448    AssertComRCReturnVoid (autoCaller.rc());
     449
     450    AutoLock alock (this);
     451
    406452    AssertReturn (
    407453        aState == USBDeviceState_USBDeviceUnavailable ||
     
    422468    }
    423469}
     470#endif
    424471
    425472/**
     
    433480 *      USBController::hasMatchingFilter (IUSBDevice *)
    434481 *      in the sense of the device matching logic.
     482 *
     483 *  @note Locks this object for reading.
    435484 */
    436485bool HostUSBDevice::isMatch (const USBDeviceFilter::Data &aData)
    437486{
    438     AutoLock alock (this);
    439     AssertReturn (isReady(), false);
     487    AutoCaller autoCaller (this);
     488    AssertComRCReturn (autoCaller.rc(), false);
     489
     490    AutoReaderLock alock (this);
    440491
    441492    if (!aData.mActive)
    442493        return false;
    443494
    444     if (!aData.mVendorId.isMatch (m_pUsb->idVendor))
     495    if (!aData.mVendorId.isMatch (mUsb->idVendor))
    445496    {
    446497        LogFlowMember (("HostUSBDevice::isMatch: vendor not match %04X\n",
    447                         m_pUsb->idVendor));
     498                        mUsb->idVendor));
    448499        return false;
    449500    }
    450     if (!aData.mProductId.isMatch (m_pUsb->idProduct))
     501    if (!aData.mProductId.isMatch (mUsb->idProduct))
    451502    {
    452503        LogFlowMember (("HostUSBDevice::isMatch: product id not match %04X\n",
    453                         m_pUsb->idProduct));
     504                        mUsb->idProduct));
    454505        return false;
    455506    }
    456     if (!aData.mRevision.isMatch (m_pUsb->bcdDevice))
     507    if (!aData.mRevision.isMatch (mUsb->bcdDevice))
    457508    {
    458509        LogFlowMember (("HostUSBDevice::isMatch: rev not match %04X\n",
    459                         m_pUsb->bcdDevice));
     510                        mUsb->bcdDevice));
    460511        return false;
    461512    }
     
    463514#if !defined (__WIN__)
    464515    // these filters are temporarily ignored on Win32
    465     if (!aData.mManufacturer.isMatch (Bstr (m_pUsb->pszManufacturer)))
    466         return false;
    467     if (!aData.mProduct.isMatch (Bstr (m_pUsb->pszProduct)))
    468         return false;
    469     if (!aData.mSerialNumber.isMatch (Bstr (m_pUsb->pszSerialNumber)))
     516    if (!aData.mManufacturer.isMatch (Bstr (mUsb->pszManufacturer)))
     517        return false;
     518    if (!aData.mProduct.isMatch (Bstr (mUsb->pszProduct)))
     519        return false;
     520    if (!aData.mSerialNumber.isMatch (Bstr (mUsb->pszSerialNumber)))
    470521        return false;
    471522    /// @todo (dmik) pusPort is yet absent
    472 //    if (!aData.mPort.isMatch (Bstr (m_pUsb->pusPort)))
     523//    if (!aData.mPort.isMatch (Bstr (mUsb->pusPort)))
    473524//        return false;
    474525#endif
     
    504555     * If all the criteria is empty, devices which are used by the host will not match.
    505556     */
    506     if (   m_pUsb->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE
     557    if (   mUsb->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE
    507558        && aData.mVendorId.string().isEmpty()
    508559        && aData.mProductId.string().isEmpty()
     
    529580int HostUSBDevice::compare (PCUSBDEVICE pDev2)
    530581{
    531     return compare (m_pUsb, pDev2);
     582    return compare (mUsb, pDev2);
    532583}
    533584
     
    564615 *
    565616 * @param   aDev    The current device state as seen by the proxy backend.
     617 *
     618 * @note Locks this object for writing.
    566619 */
    567620bool HostUSBDevice::updateState (PCUSBDEVICE aDev)
    568621{
     622    AutoCaller autoCaller (this);
     623    AssertComRCReturn (autoCaller.rc(), false);
     624
    569625    AutoLock alock (this);
    570626
  • trunk/src/VBox/Main/include/HostUSBDeviceImpl.h

    r1 r2939  
    2525#include "VirtualBoxBase.h"
    2626#include "USBDeviceFilterImpl.h"
    27 /* #include "USBProxyService.h" circular on Host/HostUSBDevice, the includer must include this. */
     27/* #include "USBProxyService.h" circular on Host/HostUSBDevice, the includer
     28 * must include this. */
    2829#include "Collection.h"
    2930
     
    3435
    3536/**
    36  * Object class used for the Host USBDevices property.
     37 * Object class used to hold Host USB Device properties.
    3738 */
    3839class ATL_NO_VTABLE HostUSBDevice :
     40    public VirtualBoxBaseNEXT,
    3941    public VirtualBoxSupportErrorInfoImpl <HostUSBDevice, IHostUSBDevice>,
    4042    public VirtualBoxSupportTranslation <HostUSBDevice>,
    41     public VirtualBoxBase,
    4243    public IHostUSBDevice
    4344{
    4445public:
    4546
    46     HostUSBDevice();
    47     virtual ~HostUSBDevice();
     47    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostUSBDevice)
    4848
    4949    DECLARE_NOT_AGGREGATABLE(HostUSBDevice)
     
    5959    NS_DECL_ISUPPORTS
    6060
     61    DECLARE_EMPTY_CTOR_DTOR (HostUSBDevice)
     62
     63    HRESULT FinalConstruct();
     64    void FinalRelease();
     65
    6166    // public initializer/uninitializer for internal purposes only
    6267    HRESULT init(PUSBDEVICE aUsb, USBProxyService *aUSBProxyService);
     68    void uninit();
    6369
    6470    // IUSBDevice properties
     
    7985    // public methods only for internal purposes
    8086
    81     const Guid &id() { return mId; }
    82     USBDeviceState_T state() { return mState; }
     87    /* @note Must be called from under the object read lock. */
     88    const Guid &id() const { return mId; }
     89
     90    /* @note Must be called from under the object read lock. */
     91    USBDeviceState_T state() const { return mState; }
     92
     93    /* @note Must be called from under the object read lock. */
     94    USBDeviceState_T pendingState() const { return mPendingState; }
     95
     96    /* @note Must be called from under the object read lock. */
    8397    ComObjPtr <SessionMachine, ComWeakRef> &machine() { return mMachine; }
     98
     99/// @todo remove
     100#if 0
     101    /* @note Must be called from under the object read lock. */
    84102    bool isIgnored() { return mIgnored; }
     103#endif
     104
     105    /* @note Must be called from under the object read lock. */
     106    bool isStatePending() const { return mIsStatePending; }
     107
     108    /* @note Must be called from under the object read lock. */
     109    PCUSBDEVICE usbData() const { return mUsb; }
    85110
    86111    Utf8Str name();
    87112
     113/// @todo remove
     114#if 0
    88115    void setIgnored();
     116#endif
     117
    89118    bool setCaptured (SessionMachine *aMachine);
    90119    int  setHostDriven();
    91120    int  reset();
    92121
     122/// @todo remove
     123#if 0
    93124    void setHostState (USBDeviceState_T aState);
     125#endif
    94126
    95127    bool isMatch (const USBDeviceFilter::Data &aData);
     
    105137private:
    106138
    107     Guid mId;
     139    const Guid mId;
    108140    USBDeviceState_T mState;
     141    USBDeviceState_T mPendingState;
    109142    ComObjPtr <SessionMachine, ComWeakRef> mMachine;
    110     bool mIgnored;
     143    bool mIsStatePending : 1;
     144/// @todo remove
     145#if 0
     146    bool mIgnored : 1;
     147#endif
     148
    111149    /** Pointer to the USB Proxy Service instance. */
    112150    USBProxyService *mUSBProxyService;
     
    114152    /** Pointer to the USB Device structure owned by this device.
    115153     * Only used for host devices. */
    116     PUSBDEVICE m_pUsb;
     154    PUSBDEVICE mUsb;
    117155};
    118156
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette