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

WDM-KS: don't request a zero buffer size #762

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

dechamps
Copy link
Contributor

@dechamps dechamps commented Jan 21, 2023

This fixes an issue where Pa_OpenStream() would fail on WDM-KS WaveRT devices if suggestedLatency is zero.

Fixes #761

src/hostapi/wdmks/pa_win_wdmks.c Outdated Show resolved Hide resolved
src/hostapi/wdmks/pa_win_wdmks.c Outdated Show resolved Hide resolved
@RossBencina
Copy link
Collaborator

If this is a workaround for KSRTAUDIO_BUFFER_PROPERTY/RequestedBufferSize not accepting zero, then I think that the the clamp to 1 should be performed just prior to the KSRTAUDIO_BUFFER_PROPERTY command rather than the current patch which reads to me like some kind of long-range action at a distance. Just a suggestion/opinion though. I'm open to any alternate reasoning that would reject my perspective.

I've made other comments at #761, we should try to keep the bulk of the discussion there.

@dechamps
Copy link
Contributor Author

dechamps commented Feb 2, 2023

@RossBencina

I think that the the clamp to 1 should be performed just prior to the KSRTAUDIO_BUFFER_PROPERTY command rather than the current patch which reads to me like some kind of long-range action at a distance

My reasoning for doing it that way is that (1) in general it feels safer to have framesPerBuffer set to at least 1, regardless of which particular WDM-KS API is used; and (2) it makes the PA_DEBUG statement on the next line less confusing - if the clamping is done later then the debug log becomes misleading.

@dechamps dechamps requested a review from philburk February 2, 2023 21:14
@RossBencina RossBencina added the src-wdmks MS WDM/KS Host API /src/hostapi/wdmks label Feb 13, 2023
Copy link
Collaborator

@philburk philburk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine except for long lines.

src/hostapi/wdmks/pa_win_wdmks.c Outdated Show resolved Hide resolved
src/hostapi/wdmks/pa_win_wdmks.c Outdated Show resolved Hide resolved
@RossBencina
Copy link
Collaborator

RossBencina commented Feb 13, 2023

@dechamps I'm not completely persuaded by your reasoning because I think my solution guarantees that 0 will not ever be passed to KSRTAUDIO_BUFFER_PROPERTY/RequestedBufferSize whereas your solution relies on maintaining an undocumented invariant "at a distance".

Could we at least add a comment in the code directly prior to where KSRTAUDIO_BUFFER_PROPERTY/RequestedBufferSize is set noting that passing 0 will fail with WinRT devices (do you mean WAVERT? not WinRT?) and linking to #761

Other possible solutions would be:

  • add an assert !=0 at RequestedBufferSize site (don't do this!)
  • put the clamp at both places.

In the end I'm not going to die on this hill but I'm not entirely comfortable with the patch as it stands.

@RossBencina RossBencina added this to the V19.8 milestone Feb 13, 2023
@dechamps dechamps force-pushed the kssl branch 3 times, most recently from ea18548 to 1adff7b Compare February 18, 2023 11:40
@dechamps
Copy link
Contributor Author

@RossBencina

Could we at least add a comment in the code directly prior to where KSRTAUDIO_BUFFER_PROPERTY/RequestedBufferSize is set noting that passing 0 will fail with WinRT devices (do you mean WAVERT? not WinRT?) and linking to #761

Done.

do you mean WAVERT? not WinRT?

Oh wow, good catch. I don't know why I wrote WinRT literally everywhere including in my original bug report, what a brain glitch… fixed in all places.

@dechamps dechamps requested a review from philburk February 18, 2023 11:44
@dechamps
Copy link
Contributor Author

The two failing checks are not caused by this PR. Filed #767 to fix the checks.

@philburk philburk requested a review from RossBencina February 19, 2023 01:24
Copy link
Collaborator

@RossBencina RossBencina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou!

This fixes an issue where Pa_OpenStream() would fail on WDM-KS WaveRT
devices if suggestedLatency is zero.

Fixes PortAudio#761
@dechamps
Copy link
Contributor Author

I guess this can be merged now?

@RossBencina RossBencina merged commit 68e963a into PortAudio:master Mar 13, 2023
@dechamps dechamps deleted the kssl branch May 25, 2024 19:12
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 this pull request may close these issues.

WDM-KS fails to open WaveRT devices with suggestedLatency=0
3 participants