Skip to content

Commit

Permalink
Fix to avoid allocation/garbage when submitting OpenAL buffers. (#8178)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParanoidCactus committed Feb 15, 2024
1 parent 2b4e406 commit c6e47a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MonoGame.Framework/Platform/Audio/OALSoundBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class OALSoundBuffer : IDisposable

public OALSoundBuffer()
{
AL.GenBuffers(1, out openALDataBuffer);
AL.GenBuffer(out openALDataBuffer);
ALHelper.CheckError("Failed to generate OpenAL data buffer.");
}

Expand Down
9 changes: 5 additions & 4 deletions MonoGame.Framework/Platform/Audio/OpenAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,12 @@ internal unsafe static void GenBuffers(int count, out int[] buffers)
}
}

internal static void GenBuffers(int count, out int buffer)
internal unsafe static void GenBuffer(out int buffer)
{
int[] ret;
GenBuffers(count, out ret);
buffer = ret[0];
fixed (int* ptr = &buffer)
{
alGenBuffers(1, ptr);
}
}

internal static int[] GenBuffers(int count)
Expand Down

0 comments on commit c6e47a1

Please sign in to comment.