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

Strange redefine numBytesRendered in DSoundStream #18968

Open
GermanAizek opened this issue Apr 2, 2024 · 2 comments
Open

Strange redefine numBytesRendered in DSoundStream #18968

GermanAizek opened this issue Apr 2, 2024 · 2 comments
Labels
Milestone

Comments

@GermanAizek
Copy link
Contributor

GermanAizek commented Apr 2, 2024

@hrydgard,
why is there redefinition numBytesRendered in this section code?
Is it intentional to call callback with parameter?

int numBytesToRender = RoundDown128(ModBufferSize(currentPos_ - lastPos_));
if (numBytesToRender >= 256) {
int numBytesRendered = 4 * (*callback_)(realtimeBuffer_, numBytesToRender >> 2, 44100);
//We need to copy the full buffer, regardless of what the mixer claims to have filled
//If we don't do this then the sound will loop if the sound stops and the mixer writes only zeroes
numBytesRendered = numBytesToRender;
WriteDataToBuffer(lastPos_, (char *) realtimeBuffer_, numBytesRendered);

@hrydgard
Copy link
Owner

hrydgard commented Apr 2, 2024

That looks weird indeed. this is ancient code (10+ years old) so I don't remember if there was a reason. will look into it.

@anr2me
Copy link
Collaborator

anr2me commented Apr 2, 2024

It came from this PR #4447
May be it's mistakenly swapped between numBytesRendered and numBytesToRender ...

@hrydgard hrydgard added this to the v1.18.0 milestone Apr 2, 2024
@hrydgard hrydgard added the Audio label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants