VirtualBox

Changeset 2967 in vbox for trunk


Ignore:
Timestamp:
May 31, 2007 7:37:43 PM (18 years ago)
Author:
vboxsync
Message:

async capture/hold/release of usb devices. (untested)

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBFE/USBProxyService.h

    r676 r2967  
    6565
    6666    /**
    67      * A VM is releaseing a device back to be held or assigned to another VM.
     67     * A VM is releasing a device back to be held or assigned to another VM.
    6868     * A port reset should be performed.
    6969     *
  • trunk/src/VBox/Main/USBProxyService.cpp

    r2587 r2967  
    224224                 * Device still there, update the state and move on.
    225225                 */
    226                 if (DevPtr->updateState (pDevices))
     226                if (updateDeviceState (DevPtr, pDevices))
    227227                    mHost->onUSBDeviceStateChanged (DevPtr);
    228228                It++;
     
    230230                pDevices = pDevices->pNext; /* treated as singly linked */
    231231                freeDevice (pFree);
    232                 /** @todo detect status changes! */
    233232            }
    234233            else
     
    255254                {
    256255                    /*
    257                      * DevPtr was detached.
     256                     * DevPtr was detached, unless there is a pending async request.
    258257                     */
    259                     It = mDevices.erase (It);
    260                     mHost->onUSBDeviceDetached (DevPtr);
    261                     Log (("USBProxyService::processChanges: detached %p\n", (HostUSBDevice *)DevPtr)); /** @todo add details .*/
     258                    /** @todo add a timeout here. */
     259                    if (!DevPtr->isStatePendingUnlocked())
     260                    {
     261                        It = mDevices.erase (It);
     262                        mHost->onUSBDeviceDetached (DevPtr);
     263                        Log (("USBProxyService::processChanges: detached %p\n", (HostUSBDevice *)DevPtr)); /** @todo add details .*/
     264                    }
     265                    /* else: operation pending */
    262266                }
    263267            }
     
    372376
    373377
     378bool USBProxyService::updateDeviceStateFake (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice)
     379{
     380    if (aDevice->isStatePendingUnlocked())
     381    {
     382        switch (aDevice->pendingStateUnlocked())
     383        {
     384            case USBDeviceState_USBDeviceCaptured:      aUSBDevice->enmState = USBDEVICESTATE_USED_BY_GUEST; break;
     385            case USBDeviceState_USBDeviceHeld:          aUSBDevice->enmState = USBDEVICESTATE_HELD_BY_PROXY; break;
     386            case USBDeviceState_USBDeviceAvailable:     aUSBDevice->enmState = USBDEVICESTATE_UNUSED; break;
     387            case USBDeviceState_USBDeviceUnavailable:   aUSBDevice->enmState = USBDEVICESTATE_USED_BY_HOST; break;
     388            case USBDeviceState_USBDeviceBusy:          aUSBDevice->enmState = USBDEVICESTATE_USED_BY_HOST_CAPTURABLE; break;
     389            default:
     390                AssertMsgFailed(("%d\n", aDevice->pendingStateUnlocked()));
     391                break;
     392        }
     393    }
     394
     395    return USBProxyService::updateDeviceState (aDevice, aUSBDevice);
     396}
     397
     398
    374399
    375400/* Stubs which the host specific classes overrides: */
     
    443468}
    444469
     470
     471bool USBProxyService::updateDeviceState (HostUSBDevice *pDevice, PUSBDEVICE pUSBDevice)
     472{
     473    return pDevice->updateState (pUSBDevice);
     474}
     475
  • trunk/src/VBox/Main/include/HostUSBDeviceImpl.h

    r2939 r2967  
    9191    USBDeviceState_T state() const { return mState; }
    9292
     93    /** Same as state() except you don't need to lock any thing. */
     94    USBDeviceState_T stateUnlocked() const
     95    {
     96        AutoReaderLock (this);
     97        return state();
     98    }
     99
    93100    /* @note Must be called from under the object read lock. */
    94101    USBDeviceState_T pendingState() const { return mPendingState; }
    95102
     103    /** Same as pendingState() except you don't need to lock any thing. */
     104    USBDeviceState_T pendingStateUnlocked() const
     105    {
     106        AutoReaderLock (this);
     107        return pendingState();
     108    }
     109
    96110    /* @note Must be called from under the object read lock. */
    97111    ComObjPtr <SessionMachine, ComWeakRef> &machine() { return mMachine; }
     
    105119    /* @note Must be called from under the object read lock. */
    106120    bool isStatePending() const { return mIsStatePending; }
     121
     122    /** Same as isStatePending() except you don't need to lock any thing. */
     123    bool isStatePendingUnlocked() const
     124    {
     125        AutoReaderLock (this);
     126        return isStatePending();
     127    }
    107128
    108129    /* @note Must be called from under the object read lock. */
  • trunk/src/VBox/Main/include/USBProxyService.h

    r2853 r2967  
    8484
    8585    /**
     86     * Updates the device state.
     87     * This is responsible for calling HostUSBDevice::updateState() and check for async completion.
     88     *
     89     * @returns true if there is a state change.
     90     * @param   pDevice     The device in question.
     91     * @param   pUSBDevice  The USB device structure for the last enumeration.
     92     */
     93    virtual bool updateDeviceState (HostUSBDevice *pDevice, PUSBDEVICE pUSBDevice);
     94
     95    /**
    8696     * Query if the service is active and working.
    8797     *
     
    150160
    151161    /**
    152      * First call made on the service thread, use it to do 
     162     * First call made on the service thread, use it to do
    153163     * thread initialization.
    154164     */
     
    156166
    157167    /**
    158      * First call made on the service thread, use it to do 
     168     * First call made on the service thread, use it to do
    159169     * thread termination.
    160170     */
    161171    virtual void serviceThreadTerm (void);
     172
     173    /**
     174     * Implement fake capture, ++.
     175     *
     176     * @returns true if there is a state change.
     177     * @param   pDevice     The device in question.
     178     * @param   pUSBDevice  The USB device structure for the last enumeration.
     179     */
     180    bool updateDeviceStateFake (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice);
     181
    162182
    163183public:
     
    223243    virtual int releaseDevice (HostUSBDevice *aDevice);
    224244    virtual int resetDevice (HostUSBDevice *aDevice);
     245    virtual bool updateDeviceState (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice);
    225246
    226247protected:
     
    232253
    233254private:
    234     /** Reference to the runloop of the service thread. 
     255    /** Reference to the runloop of the service thread.
    235256     * This is NULL if the service thread isn't running. */
    236257    CFRunLoopRef mServiceRunLoopRef;
    237258    /** The opaque value returned by DarwinSubscribeUSBNotifications. */
    238259    void *mNotifyOpaque;
    239     /** A hack to work around the problem with the usb device enumeration 
     260    /** A hack to work around the problem with the usb device enumeration
    240261     * not including newly attached devices. */
    241262    bool mWaitABitNextTime;
     
    260281    virtual int releaseDevice (HostUSBDevice *aDevice);
    261282    virtual int resetDevice (HostUSBDevice *aDevice);
     283    virtual bool updateDeviceState (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice);
    262284
    263285protected:
     
    298320    virtual int releaseDevice (HostUSBDevice *aDevice);
    299321    virtual int resetDevice (HostUSBDevice *aDevice);
     322    virtual bool updateDeviceState (HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice);
    300323
    301324protected:
Note: See TracChangeset for help on using the changeset viewer.

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