aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-06-16 18:58:56 -0700
committerChris Robinson <[email protected]>2019-06-16 18:58:56 -0700
commita009b9502a59658f4e60b4c8c6313fa5d7b6dd46 (patch)
tree7e5522df31b4e0981ce63527811342f75ebe4a2a /Alc/alc.cpp
parent0a532729baeeaaf7e8bd7d9c20105668ca38665f (diff)
Avoid manually looping to destroy orphaned async events
Diffstat (limited to 'Alc/alc.cpp')
-rw-r--r--Alc/alc.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 1299e8e2..3c59782f 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2516,22 +2516,19 @@ ALCcontext::~ALCcontext()
{
count = 0;
auto evt_vec = AsyncEvents->getReadVector();
- while(evt_vec.first.len > 0)
+ if(evt_vec.first.len > 0)
{
- al::destroy_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf));
- evt_vec.first.buf += sizeof(AsyncEvent);
- evt_vec.first.len -= 1;
- ++count;
+ al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), evt_vec.first.len);
+ count += evt_vec.first.len;
}
- while(evt_vec.second.len > 0)
+ if(evt_vec.second.len > 0)
{
- al::destroy_at(reinterpret_cast<AsyncEvent*>(evt_vec.second.buf));
- evt_vec.second.buf += sizeof(AsyncEvent);
- evt_vec.second.len -= 1;
- ++count;
+ al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.second.buf), evt_vec.second.len);
+ count += evt_vec.second.len;
}
if(count > 0)
TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s");
+ AsyncEvents->readAdvance(count);
}
ALCdevice_DecRef(Device);