aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alSource.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-25 08:42:43 -0800
committerChris Robinson <[email protected]>2018-11-25 08:42:43 -0800
commitbf4518fe5cbe708b3d6b44855f05b58008a48cc8 (patch)
tree60482d67644528cdbfcdb6d31691be1947362dc4 /OpenAL32/alSource.cpp
parent7c0605f09eabb55cd3f1b85474b31bfae584cde9 (diff)
Atuomatically clean up sources with its sublist's destruction
Diffstat (limited to 'OpenAL32/alSource.cpp')
-rw-r--r--OpenAL32/alSource.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp
index 0955d1e9..8b461982 100644
--- a/OpenAL32/alSource.cpp
+++ b/OpenAL32/alSource.cpp
@@ -3399,28 +3399,19 @@ void UpdateAllSourceProps(ALCcontext *context)
);
}
-/* ReleaseALSources
- *
- * Destroys all sources in the source map.
- */
-ALvoid ReleaseALSources(ALCcontext *context)
+SourceSubList::~SourceSubList()
{
- size_t leftover = 0;
- for(auto &sublist : context->SourceList)
+ ALuint64 usemask = ~FreeMask;
+ while(usemask)
{
- ALuint64 usemask = ~sublist.FreeMask;
- while(usemask)
- {
- ALsizei idx{CTZ64(usemask)};
- ALsource *source{sublist.Sources + idx};
+ ALsizei idx{CTZ64(usemask)};
+ ALsource *source{Sources + idx};
- source->~ALsource();
- ++leftover;
+ source->~ALsource();
- usemask &= ~(U64(1) << idx);
- }
- sublist.FreeMask = ~usemask;
+ usemask &= ~(U64(1) << idx);
}
- if(leftover > 0)
- WARN("(%p) Deleted " SZFMT " Source%s\n", context, leftover, (leftover==1)?"":"s");
+ FreeMask = ~usemask;
+ al_free(Sources);
+ Sources = nullptr;
}