aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alBuffer.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-25 15:30:32 -0800
committerChris Robinson <[email protected]>2018-11-25 15:30:32 -0800
commit8ae07ad1ae2d957f65ba54fdcd19649eceeb0e3d (patch)
treeb26085490d71fdb2e0968bfd79c90c3dd3613764 /OpenAL32/alBuffer.cpp
parent05845b53e889c2104a5436ff5418c5e2ba5dcbf3 (diff)
Automatically clean up buffers with ther sublist
Diffstat (limited to 'OpenAL32/alBuffer.cpp')
-rw-r--r--OpenAL32/alBuffer.cpp32
1 files changed, 9 insertions, 23 deletions
diff --git a/OpenAL32/alBuffer.cpp b/OpenAL32/alBuffer.cpp
index 5c40a27e..3716ac28 100644
--- a/OpenAL32/alBuffer.cpp
+++ b/OpenAL32/alBuffer.cpp
@@ -1174,30 +1174,16 @@ ALsizei ChannelsFromFmt(FmtChannels chans)
}
-/*
- * ReleaseALBuffers()
- *
- * INTERNAL: Called to destroy any buffers that still exist on the device
- */
-ALvoid ReleaseALBuffers(ALCdevice *device)
+BufferSubList::~BufferSubList()
{
- size_t leftover = 0;
- for(auto &sublist : device->BufferList)
+ ALuint64 usemask = ~FreeMask;
+ while(usemask)
{
- ALuint64 usemask = ~sublist.FreeMask;
- while(usemask)
- {
- ALsizei idx = CTZ64(usemask);
- ALbuffer *buffer = sublist.Buffers + idx;
-
- buffer->~ALbuffer();
-
- ++leftover;
-
- usemask &= ~(U64(1) << idx);
- }
- sublist.FreeMask = ~usemask;
+ ALsizei idx{CTZ64(usemask)};
+ Buffers[idx].~ALbuffer();
+ usemask &= ~(U64(1) << idx);
}
- if(leftover > 0)
- WARN("(%p) Deleted " SZFMT " Buffer%s\n", device, leftover, (leftover==1)?"":"s");
+ FreeMask = ~usemask;
+ al_free(Buffers);
+ Buffers = nullptr;
}