diff options
Diffstat (limited to 'src/VBox/Devices/USB/VUSBReadAhead.cpp')
| -rw-r--r-- | src/VBox/Devices/USB/VUSBReadAhead.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/VBox/Devices/USB/VUSBReadAhead.cpp b/src/VBox/Devices/USB/VUSBReadAhead.cpp index 69ba7f56..8c16dc41 100644 --- a/src/VBox/Devices/USB/VUSBReadAhead.cpp +++ b/src/VBox/Devices/USB/VUSBReadAhead.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2009 Oracle Corporation + * Copyright (C) 2006-2010 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -173,7 +173,8 @@ static DECLCALLBACK(int) vusbDevReadAheadThread(RTTHREAD Thread, void *pvUser) /* The previous read-ahead thread could be still running (vusbReadAheadStop sets only * fTerminate to true and returns immediately). Therefore we have to wait until the * previous thread is done and all submitted URBs are completed. */ - while (pPipe->cSubmitted > 0) + while ( pPipe->cSubmitted > 0 + && pPipe->cBuffered > 0) { Log2(("vusbDevReadAheadThread: still %u packets submitted, waiting before starting...\n", pPipe->cSubmitted)); RTThreadSleep(1); @@ -245,6 +246,22 @@ static DECLCALLBACK(int) vusbDevReadAheadThread(RTTHREAD Thread, void *pvUser) RTThreadSleep(1); } + /* + * Free all still buffered URBs because another endpoint with a different packet size + * and complete different data formats might be served later. + */ + int cFree = 0; + while (pPipe->pBuffUrbHead) + { + PVUSBURB pBufferedUrb = pPipe->pBuffUrbHead; + + pPipe->pBuffUrbHead = pBufferedUrb->Hci.pNext; + pBufferedUrb->VUsb.pfnFree(pBufferedUrb); + cFree++; + } + + pPipe->pBuffUrbTail = NULL; + pPipe->cBuffered = 0; RTMemTmpFree(pArgs); return rc; @@ -368,10 +385,11 @@ void vusbReadAheadStart(PVUSBDEV pDev, PVUSBPIPE pPipe) if (pArgs) { + PVUSBROOTHUB pRh = vusbDevGetRh(pDev); pArgs->pDev = pDev; pArgs->pPipe = pPipe; pArgs->fTerminate = false; - pArgs->fHighSpeed = ((vusbDevGetRh(pDev)->fHcVersions & VUSB_STDVER_20) != 0); + pArgs->fHighSpeed = pRh && ((pRh->fHcVersions & VUSB_STDVER_20) != 0); if (pArgs->fHighSpeed) rc = RTThreadCreate(&pPipe->ReadAheadThread, vusbDevReadAheadThread, pArgs, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "USBISOC"); else |
