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

Assert may not have been a NOOP #962

Open
philburk opened this issue Sep 26, 2024 · 1 comment
Open

Assert may not have been a NOOP #962

philburk opened this issue Sep 26, 2024 · 1 comment
Assignees
Labels
src-wasapi MS WASAPI Host API /src/hostapi/wasapi

Comments

@philburk
Copy link
Collaborator

In a review of a WASAPI change I stated that an assert was a NOOP.

Originally posted by @philburk in #948 (comment)

But after rereading the code I realize that I misread line 1425. I thought it was checking "subtream->monoBuffer". But it was checking "subtream->monoMixer". So the assert(subtream->monoBuffer != NULL) actually did something.

If Dmitry wants to add it back in that is fine with me.

@RossBencina RossBencina added the src-wasapi MS WASAPI Host API /src/hostapi/wasapi label Sep 26, 2024
@dmitrykos
Copy link
Collaborator

dmitrykos commented Sep 27, 2024

I replaced this assert with a new one to assert the reason rather than consequence to assist the understanding of the logic:

assert(subStream->wavexu.ext.Format.nBlockAlign != 0);

subtream->monoBuffer can become NULL in that piece of logic only if this condition fails when monoBufferSize is 0 because initially subStream->monoBufferSize is 0 and it is set only inside this function when monoBuffer is allocated successfully:

UINT32 monoBufferSize = frames * subStream->wavexu.ext.Format.nBlockAlign;
if (monoBufferSize > subStream->monoBufferSize)

but it will not happen if frames and nBlockAlign are not 0. So for now I think assert(subtream->monoBuffer != NULL) is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src-wasapi MS WASAPI Host API /src/hostapi/wasapi
Projects
None yet
Development

No branches or pull requests

3 participants