USBCAMD and USB connector unplugging while application is running?

Discussion in 'Windows Vista Drivers' started by PVV, Apr 21, 2009.

  1. PVV

    PVV Guest

    I've got my driver based on USBCAMD. Assume that application is
    running, "Preview" is ON (AMCap, for example) and if I unplug USB device
    from PC, my application (or driver) hangs.
    How can I repare this?
    I tried to delay calling of USBCAMD_AdapterReceivePacket during
    SRB_SURPRISE_REMOVAL processing but it does not work if the target device
    is connected to USB hub and hub's connector is unplugged.

    Thank you.
    PVV, Apr 21, 2009
    1. Advertisements

  2. PVV

    Tim Roberts Guest

    You shouldn't have to to anything special. USBCAMD2 should handle
    SRB_SURPRISE_REMOVAL for you. Are you setting *Completed to false to let
    USBCAMD2 have a shot? Where does it hang?
    Tim Roberts, Apr 23, 2009
    1. Advertisements

  3. PVV

    PVV Guest

    No. It was as in DDK usbintel example:

    // let usbcamd handle it
    deviceContext =
    It's better to say that it hangs when I try to call any program interface
    related to the device

    You can see what I receive if ÐМСap Prewiew is turned off and usb connector
    is unplugging
    (I monitor state of my driver by DbgPrint and DebugView or debugger ):

    'MYCAM: 'AdapterReceivePacket = 0x10E
    'MYCAM: 'StopVideoCapture
    'MYCAM: 'FreeBandwidth
    'MYCAM: 'AdapterReceivePacket = 0x109
    'MYCAM: 'UnInitialize

    AMCap error window contains "Stopping Capture (Device Lost). Select New
    Capture Device". (msg WM_FGNOTIFY)
    and device becames inaccessible

    Now one can choose another device or close the application.
    After closing of the application:

    'MYCAM: 'AdapterReceivePacket = 0x102
    'MYCAM: 'AdapterReceivePacket = 0x111

    If Preview is ON:

    'MYCAM: 'MYCAM_ReceiveDataPacket
    'MYCAM: 'MYCAM_NewFrameEx
    'MYCAM: frameBuffer = 0x9c2f1040 max = 10265616 numpackets = 0
    'MYCAM: rawFrameBuffer = 0x858a5000 max = 3421872
    'MYCAM: 'ProcessRawVideoFrame return length = 10265616
    'MYCAM: 'AdapterReceivePacket = 0x10E
    'MYCAM: 'MYCAM_ReceiveDataPacket
    'MYCAM: 'StopVideoCapture
    'MYCAM: 'FreeBandwidth

    (In another system even StopVideoCapture, FreeBandwidth don't came.)

    AMCap does not output error message and hangs when I try to close the
    One can see the device in "Device Manager".
    When I close AMCap "by hand":

    'MYCAM: 'AdapterReceivePacket = 0x109
    'MYCAM: 'UnInitialize
    'MYCAM: 'AdapterReceivePacket = 0x102
    'MYCAM: 'AdapterReceivePacket = 0x111
    PVV, Apr 23, 2009
  4. PVV

    Tim Roberts Guest

    OK, that's all correct. So, what is the problem? The device is not
    supposed to be accessible after getting EC_DEVICE_LOST. Or, are you saying
    this part works fine?
    Are you submitting more URBs after the call to StopVideoCapture?
    Tim Roberts, Apr 25, 2009
  5. PVV

    PVV Guest

    Yes, this part is OK.

    No, I am not sending more URBs after the call to StopVideoCapture.
    PVV, Apr 28, 2009
  6. PVV

    Tim Roberts Guest

    Then I'm not clear why it would hang. How much debugging have you done? Do
    you start any threads in your driver that, perhaps, aren't getting cleaned
    Tim Roberts, Apr 29, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.