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

Avoid array resizing in OpenAlAsyncLoadSound. #14436

Merged
merged 1 commit into from Dec 11, 2017

Conversation

Projects
None yet
3 participants
@RoosterDragon
Member

RoosterDragon commented Nov 27, 2017

  • Where it is accessible, use the length of the stream to presize the MemoryStream to the correct size.
  • Instead of copying out the result via ToArray, grab the underlying buffer via GetBuffer and use that to create the sound source.

This avoids extraneous copying of the array containing the audio.

Helps with #12494 by allocating less when music tracks switch, reducing peak memory.

@pchote pchote added this to the Next release milestone Dec 9, 2017

@pchote

LGTM otherwise 👍

Tested with the default mods, and rebased back to the old bleed version used by the ra2 mod to test wav music.

Avoid array resizing in OpenAlAsyncLoadSound.
- Where it is accessible, use the length of the stream to presize the MemoryStream to the correct size.
- Instead of copying out the result via ToArray, grab the underlying buffer via GetBuffer and use that to create the sound source.

This avoids extraneous copying of the array containing the audio.
@pchote

pchote approved these changes Dec 11, 2017

@abcdefg30 abcdefg30 merged commit 7760c41 into OpenRA:bleed Dec 11, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@abcdefg30

This comment has been minimized.

Show comment
Hide comment
@abcdefg30
Member

abcdefg30 commented Dec 11, 2017

@RoosterDragon RoosterDragon deleted the RoosterDragon:async-sound-avoid-resize branch Dec 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment