aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-10-08 11:05:36 -0700
committerChris Robinson <[email protected]>2021-10-08 11:05:36 -0700
commite3b8f8fe272503ef7f738da2f577f68b0fe16eeb (patch)
treedbcedc04132f1471f651984f9b5726678cca3443 /alc
parent8da4eaff29972aca8932c75084d1f1698da5e762 (diff)
Make a construct_at method amd use it
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp8
-rw-r--r--alc/backends/pipewire.cpp8
-rw-r--r--alc/effectslot.cpp2
3 files changed, 10 insertions, 8 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp
index ac6c27ec..6d1fb2af 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -468,7 +468,8 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBa
auto evt_vec = ring->getWriteVector();
if LIKELY(evt_vec.first.len > 0)
{
- AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_ReleaseEffectState}};
+ AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
+ EventType_ReleaseEffectState)};
evt->u.mEffectState = oldstate;
ring->writeAdvance(1);
}
@@ -1556,7 +1557,8 @@ void SendSourceStateEvent(ContextBase *context, uint id, VChangeState state)
auto evt_vec = ring->getWriteVector();
if(evt_vec.first.len < 1) return;
- AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_SourceStateChange}};
+ AsyncEvent *evt{al::construct_at(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf),
+ EventType_SourceStateChange)};
evt->u.srcstate.id = id;
switch(state)
{
@@ -2038,7 +2040,7 @@ void DeviceBase::handleDisconnect(const char *msg, ...)
auto evt_data = ring->getWriteVector().first;
if(evt_data.len > 0)
{
- ::new(evt_data.buf) AsyncEvent{evt};
+ al::construct_at(reinterpret_cast<AsyncEvent*>(evt_data.buf), evt);
ring->writeAdvance(1);
ctx->mEventSem.post();
}
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index bbab7204..82b7a22f 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -873,8 +873,8 @@ void EventManager::addCallback(uint32_t id, uint32_t, const char *type, uint32_t
/* Initialize the NodeProxy to hold the proxy object, add it to the
* active proxy list, and update the sync point.
*/
- auto *node = ::new(pw_proxy_get_user_data(proxy)) NodeProxy{id, proxy};
- mProxyList.emplace_back(node);
+ auto *node = static_cast<NodeProxy*>(pw_proxy_get_user_data(proxy));
+ mProxyList.emplace_back(al::construct_at(node, id, proxy));
syncInit();
}
else if(std::strcmp(type, PW_TYPE_INTERFACE_Metadata) == 0)
@@ -902,8 +902,8 @@ void EventManager::addCallback(uint32_t id, uint32_t, const char *type, uint32_t
return;
}
- auto *mdata = ::new(pw_proxy_get_user_data(proxy)) MetadataProxy{id, proxy};
- mDefaultMetadata = mdata;
+ auto *mdata = static_cast<MetadataProxy*>(pw_proxy_get_user_data(proxy));
+ mDefaultMetadata = al::construct_at(mdata, id, proxy);
syncInit();
}
}
diff --git a/alc/effectslot.cpp b/alc/effectslot.cpp
index 21084f39..51fb8d46 100644
--- a/alc/effectslot.cpp
+++ b/alc/effectslot.cpp
@@ -15,7 +15,7 @@ EffectSlotArray *EffectSlot::CreatePtrArray(size_t count) noexcept
* space to store a sorted list during mixing.
*/
void *ptr{al_calloc(alignof(EffectSlotArray), EffectSlotArray::Sizeof(count*2))};
- return new(ptr) EffectSlotArray{count};
+ return al::construct_at(static_cast<EffectSlotArray*>(ptr), count);
}
EffectSlot::~EffectSlot()