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

Bounce through SDL2 heap in AudioCVT::convert #1098

Merged
merged 5 commits into from
Apr 22, 2021

Conversation

waych
Copy link
Contributor

@waych waych commented Apr 21, 2021

This commit rewrites AudioCVT::convert to bounce the audio buffer into a
an SDL2 heap allocation, rather than trying to reuse the rust heap
buffer. This is critical, as the underlying library warns internally
that the buffer may be reallocated, breaking configurations where
the library is not using the same heap as rust.

The underlying implementation also notes that the underlying buffer may
be transparently resized to larger than the output as part of the
transformations, so relying on the buffer being capacity() bytes long to
ensure the buffer is not re-allocated is a broken assumption.

Closes #1096

This commit rewrites AudioCVT::convert to bounce the audio buffer into a
an SDL2 heap allocation, rather than trying to reuse the rust heap
buffer.  This is critical, as the underlying library warns internally
that the buffer may be reallocated, breaking configurations where
the library is not using the same heap as rust.

The underlying implementation also notes that the underlying buffer may
be transparently resized to larger than the output as part of the
transformations, so relying on the buffer being capacity() bytes long to
ensure the buffer is not re-allocated is a broken assumption.

Closes Rust-SDL2#1096
@Cobrand
Copy link
Member

Cobrand commented Apr 22, 2021

Thanks! I didn't expect it to be done this quickly, I was prepared to do it myself this weekend if no one did it themselves.

Regardless, I think it looks good to go! We may have to change the doc in the future, the changes aren't really done "in place" anymore, but well, this isn't too important.

Merging!

@Cobrand Cobrand merged commit 3de6172 into Rust-SDL2:master Apr 22, 2021
@waych waych deleted the fix_audio branch April 22, 2021 16:52
sypwex pushed a commit to sypwex/rust-sdl2 that referenced this pull request Jun 2, 2024
Bounce through SDL2 heap in AudioCVT::convert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_audio_cvt crash on Windows bundled release
2 participants