Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] wdmks: clear Header.OptionsFlags before reusing packets #310

Closed
RossBencina opened this issue Oct 1, 2020 · 0 comments · Fixed by #388
Closed

[PATCH] wdmks: clear Header.OptionsFlags before reusing packets #310

RossBencina opened this issue Oct 1, 2020 · 0 comments · Fixed by #388
Labels
src-wdmks MS WDM/KS Host API /src/hostapi/wdmks
Milestone

Comments

@RossBencina
Copy link
Collaborator

RossBencina commented Oct 1, 2020

Posted to mailing list 10/5/2020:

From: Stefan Hajnoczi

Capture from a Focusrite Scarlett 2i4 (1st Gen) USB audio interface with
the Windows WDM-KS hostapi times out on Windows 8.1
pa_stable_v190600_20161030 x86_64. It works when built for i686.

The Header.OptionsFlags field is zero when the packet is first given to
the device. The value is KSSTREAM_HEADER_OPTIONSF_DURATIONVALID |
KSSTREAM_HEADER_OPTIONSF_TIMEVALID when the device completes the packet.

Reusing this packet causes the event to be signalled again immediately
with DataUsed=0. The stream fails with paTimedOut once all packets have
failed in this way.

Clear the OptionsFlags field before reusing the packet. This makes the
driver happy.

Tested both x86_64 and i686 with the Focusrite Scarlett 2i4 USB driver
version 2.5.128.1.

Signed-off-by: Stefan Hajnoczi <...>
---
I am not familiar with the WDM-KS API and this patch is a result of
debugging from first principles rather than understanding the code. Why
it worked for 32-bit and failed for 64-bit remains a mystery to me.
Please review carefully.
---
 src/hostapi/wdmks/pa_win_wdmks.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c
index 70a48d8..f95f1ba 100644
--- a/src/hostapi/wdmks/pa_win_wdmks.c
+++ b/src/hostapi/wdmks/pa_win_wdmks.c
@@ -6536,7 +6536,11 @@ static PaError PaPinCaptureSubmitHandler_WaveCyclic(PaProcessThreadInfo* pInfo,
     pInfo->capturePackets[pInfo->captureTail & cPacketsArrayMask].packet = 0;
     assert(packet != 0);
     PA_HP_TRACE((pInfo->stream->hLog, "Capture submit: %u", eventIndex));
-    packet->Header.DataUsed = 0; /* Reset for reuse */
+
+    /* Reset header for reuse */
+    packet->Header.DataUsed = 0;
+    packet->Header.OptionsFlags = 0;
+
     ResetEvent(packet->Signal.hEvent);
     result = PinRead(pInfo->stream->capture.pPin->handle, packet);
     ++pInfo->pending;
@RossBencina RossBencina added the src-wdmks MS WDM/KS Host API /src/hostapi/wdmks label Oct 1, 2020
@RossBencina RossBencina added this to the V19.7 milestone Oct 1, 2020
RossBencina added a commit to RossBencina/portaudio that referenced this issue Dec 22, 2020
RossBencina added a commit that referenced this issue Dec 27, 2020
…ssue with Focusrite Scarlett 2i4 (1st Gen). Fixes #310
illuusio pushed a commit to illuusio/portaudio that referenced this issue Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src-wdmks MS WDM/KS Host API /src/hostapi/wdmks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant