aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/alsa.cpp12
-rw-r--r--Alc/backends/base.cpp11
-rw-r--r--Alc/backends/base.h5
-rw-r--r--Alc/backends/coreaudio.cpp12
-rw-r--r--Alc/backends/dsound.cpp12
-rw-r--r--Alc/backends/jack.cpp6
-rw-r--r--Alc/backends/loopback.cpp5
-rw-r--r--Alc/backends/null.cpp6
-rw-r--r--Alc/backends/opensl.cpp12
-rw-r--r--Alc/backends/oss.cpp12
-rw-r--r--Alc/backends/portaudio.cpp12
-rw-r--r--Alc/backends/pulseaudio.cpp12
-rw-r--r--Alc/backends/qsa.cpp14
-rw-r--r--Alc/backends/sdl2.cpp19
-rw-r--r--Alc/backends/sndio.cpp12
-rw-r--r--Alc/backends/solaris.cpp6
-rw-r--r--Alc/backends/wasapi.cpp12
-rw-r--r--Alc/backends/wave.cpp6
-rw-r--r--Alc/backends/winmm.cpp12
19 files changed, 96 insertions, 102 deletions
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 97b2e965..2d0b3070 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -429,6 +429,8 @@ struct ALCplaybackAlsa final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCplaybackAlsa(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCplaybackAlsa_mixerProc(ALCplaybackAlsa *self);
@@ -451,8 +453,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCplaybackAlsa);
void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device)
{
- new (self) ALCplaybackAlsa{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCplaybackAlsa{device};
SET_VTABLE2(ALCplaybackAlsa, ALCbackend, self);
}
@@ -462,7 +463,6 @@ void ALCplaybackAlsa_Destruct(ALCplaybackAlsa *self)
snd_pcm_close(self->mPcmHandle);
self->mPcmHandle = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCplaybackAlsa();
}
@@ -932,6 +932,8 @@ struct ALCcaptureAlsa final : public ALCbackend {
RingBufferPtr mRing{nullptr};
snd_pcm_sframes_t mLastAvail{0};
+
+ ALCcaptureAlsa(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device);
@@ -952,8 +954,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCcaptureAlsa);
void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device)
{
- new (self) ALCcaptureAlsa{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCcaptureAlsa{device};
SET_VTABLE2(ALCcaptureAlsa, ALCbackend, self);
}
@@ -963,7 +964,6 @@ void ALCcaptureAlsa_Destruct(ALCcaptureAlsa *self)
snd_pcm_close(self->mPcmHandle);
self->mPcmHandle = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCcaptureAlsa();
}
diff --git a/Alc/backends/base.cpp b/Alc/backends/base.cpp
index 85f4b034..021a0f17 100644
--- a/Alc/backends/base.cpp
+++ b/Alc/backends/base.cpp
@@ -26,14 +26,11 @@ ClockLatency GetClockLatency(ALCdevice *device)
/* Base ALCbackend method implementations. */
-void ALCbackend_Construct(ALCbackend *self, ALCdevice *device)
-{
- self->mDevice = device;
-}
+ALCbackend::ALCbackend(ALCdevice *device) noexcept : mDevice{device}
+{ }
-void ALCbackend_Destruct(ALCbackend* UNUSED(self))
-{
-}
+ALCbackend::~ALCbackend()
+{ }
ALCboolean ALCbackend_reset(ALCbackend* UNUSED(self))
{
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index 15622967..aaa2b037 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -41,10 +41,11 @@ struct ALCbackend {
ALCdevice *mDevice;
std::recursive_mutex mMutex;
+
+ ALCbackend(ALCdevice *device) noexcept;
+ virtual ~ALCbackend();
};
-void ALCbackend_Construct(ALCbackend *self, ALCdevice *device);
-void ALCbackend_Destruct(ALCbackend *self);
ALCboolean ALCbackend_reset(ALCbackend *self);
ALCenum ALCbackend_captureSamples(ALCbackend *self, void *buffer, ALCuint samples);
ALCuint ALCbackend_availableSamples(ALCbackend *self);
diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp
index 8f4a8d2a..d0d0060c 100644
--- a/Alc/backends/coreaudio.cpp
+++ b/Alc/backends/coreaudio.cpp
@@ -44,6 +44,8 @@ struct ALCcoreAudioPlayback final : public ALCbackend {
ALuint mFrameSize{0u};
AudioStreamBasicDescription mFormat{}; // This is the OpenAL format as a CoreAudio ASBD
+
+ ALCcoreAudioPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void ALCcoreAudioPlayback_Construct(ALCcoreAudioPlayback *self, ALCdevice *device);
@@ -64,8 +66,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCcoreAudioPlayback);
static void ALCcoreAudioPlayback_Construct(ALCcoreAudioPlayback *self, ALCdevice *device)
{
- new (self) ALCcoreAudioPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCcoreAudioPlayback{device};
SET_VTABLE2(ALCcoreAudioPlayback, ALCbackend, self);
}
@@ -74,7 +75,6 @@ static void ALCcoreAudioPlayback_Destruct(ALCcoreAudioPlayback *self)
AudioUnitUninitialize(self->mAudioUnit);
AudioComponentInstanceDispose(self->mAudioUnit);
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCcoreAudioPlayback();
}
@@ -324,6 +324,8 @@ struct ALCcoreAudioCapture final : public ALCbackend {
SampleConverterPtr mConverter;
RingBufferPtr mRing{nullptr};
+
+ ALCcoreAudioCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void ALCcoreAudioCapture_Construct(ALCcoreAudioCapture *self, ALCdevice *device);
@@ -344,8 +346,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCcoreAudioCapture);
static void ALCcoreAudioCapture_Construct(ALCcoreAudioCapture *self, ALCdevice *device)
{
- new (self) ALCcoreAudioCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCcoreAudioCapture{device};
SET_VTABLE2(ALCcoreAudioCapture, ALCbackend, self);
}
@@ -355,7 +356,6 @@ static void ALCcoreAudioCapture_Destruct(ALCcoreAudioCapture *self)
AudioComponentInstanceDispose(self->mAudioUnit);
self->mAudioUnit = 0;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCcoreAudioCapture();
}
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 19fe8053..7bfe79df 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -193,6 +193,8 @@ struct ALCdsoundPlayback final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCdsoundPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self);
@@ -215,8 +217,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCdsoundPlayback);
void ALCdsoundPlayback_Construct(ALCdsoundPlayback *self, ALCdevice *device)
{
- new (self) ALCdsoundPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCdsoundPlayback{device};
SET_VTABLE2(ALCdsoundPlayback, ALCbackend, self);
}
@@ -239,7 +240,6 @@ void ALCdsoundPlayback_Destruct(ALCdsoundPlayback *self)
CloseHandle(self->mNotifyEvent);
self->mNotifyEvent = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCdsoundPlayback();
}
@@ -656,6 +656,8 @@ struct ALCdsoundCapture final : public ALCbackend {
DWORD mCursor{0u};
RingBufferPtr mRing;
+
+ ALCdsoundCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device);
@@ -674,8 +676,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCdsoundCapture);
void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device)
{
- new (self) ALCdsoundCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCdsoundCapture{device};
SET_VTABLE2(ALCdsoundCapture, ALCbackend, self);
}
@@ -692,7 +693,6 @@ void ALCdsoundCapture_Destruct(ALCdsoundCapture *self)
self->mDSC->Release();
self->mDSC = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCdsoundCapture();
}
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index ca537323..059f9c96 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -157,6 +157,8 @@ struct ALCjackPlayback final : public ALCbackend {
std::atomic<bool> mKillNow{true};
std::thread mThread;
+
+ ALCjackPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg);
@@ -182,8 +184,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCjackPlayback);
void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device)
{
- new (self) ALCjackPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCjackPlayback{device};
SET_VTABLE2(ALCjackPlayback, ALCbackend, self);
}
@@ -200,7 +201,6 @@ void ALCjackPlayback_Destruct(ALCjackPlayback *self)
self->mClient = nullptr;
}
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCjackPlayback();
}
diff --git a/Alc/backends/loopback.cpp b/Alc/backends/loopback.cpp
index 65c87971..9291ae77 100644
--- a/Alc/backends/loopback.cpp
+++ b/Alc/backends/loopback.cpp
@@ -29,6 +29,7 @@
namespace {
struct ALCloopback final : public ALCbackend {
+ ALCloopback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void ALCloopback_Construct(ALCloopback *self, ALCdevice *device);
@@ -48,14 +49,12 @@ DEFINE_ALCBACKEND_VTABLE(ALCloopback);
void ALCloopback_Construct(ALCloopback *self, ALCdevice *device)
{
- new (self) ALCloopback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCloopback{device};
SET_VTABLE2(ALCloopback, ALCbackend, self);
}
void ALCloopback_Destruct(ALCloopback *self)
{
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCloopback();
}
diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp
index fb113077..2b2a4b84 100644
--- a/Alc/backends/null.cpp
+++ b/Alc/backends/null.cpp
@@ -47,6 +47,8 @@ constexpr ALCchar nullDevice[] = "No Output";
struct ALCnullBackend final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCnullBackend(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCnullBackend_mixerProc(ALCnullBackend *self);
@@ -69,14 +71,12 @@ DEFINE_ALCBACKEND_VTABLE(ALCnullBackend);
void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device)
{
- new (self) ALCnullBackend{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCnullBackend{device};
SET_VTABLE2(ALCnullBackend, ALCbackend, self);
}
void ALCnullBackend_Destruct(ALCnullBackend *self)
{
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCnullBackend();
}
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index e1a0faa6..3aa2d267 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -152,6 +152,8 @@ struct ALCopenslPlayback final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCopenslPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void ALCopenslPlayback_process(SLAndroidSimpleBufferQueueItf bq, void *context);
@@ -175,8 +177,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCopenslPlayback);
static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *device)
{
- new (self) ALCopenslPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCopenslPlayback{device};
SET_VTABLE2(ALCopenslPlayback, ALCbackend, self);
}
@@ -195,7 +196,6 @@ static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self)
self->mEngineObj = NULL;
self->mEngine = NULL;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCopenslPlayback();
}
@@ -660,6 +660,8 @@ struct ALCopenslCapture final : public ALCbackend {
ALCuint mSplOffset{0u};
ALsizei mFrameSize{0};
+
+ ALCopenslCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void ALCopenslCapture_process(SLAndroidSimpleBufferQueueItf bq, void *context);
@@ -681,8 +683,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCopenslCapture);
static void ALCopenslCapture_Construct(ALCopenslCapture *self, ALCdevice *device)
{
- new (self) ALCopenslCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCopenslCapture{device};
SET_VTABLE2(ALCopenslCapture, ALCbackend, self);
}
@@ -697,7 +698,6 @@ static void ALCopenslCapture_Destruct(ALCopenslCapture *self)
self->mEngineObj = NULL;
self->mEngine = NULL;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCopenslCapture();
}
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index ec9028eb..73b62b30 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -248,6 +248,8 @@ struct ALCplaybackOSS final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCplaybackOSS(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCplaybackOSS_mixerProc(ALCplaybackOSS *self);
@@ -269,8 +271,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCplaybackOSS);
void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device)
{
- new (self) ALCplaybackOSS{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCplaybackOSS{device};
SET_VTABLE2(ALCplaybackOSS, ALCbackend, self);
}
@@ -280,7 +281,6 @@ void ALCplaybackOSS_Destruct(ALCplaybackOSS *self)
close(self->fd);
self->fd = -1;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCplaybackOSS();
}
@@ -498,6 +498,8 @@ struct ALCcaptureOSS final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCcaptureOSS(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCcaptureOSS_recordProc(ALCcaptureOSS *self);
@@ -519,8 +521,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCcaptureOSS);
void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device)
{
- new (self) ALCcaptureOSS{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCcaptureOSS{device};
SET_VTABLE2(ALCcaptureOSS, ALCbackend, self);
}
@@ -530,7 +531,6 @@ void ALCcaptureOSS_Destruct(ALCcaptureOSS *self)
close(self->fd);
self->fd = -1;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCcaptureOSS();
}
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index 354389c3..f49c0d2c 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -134,6 +134,8 @@ struct ALCportPlayback final : public ALCbackend {
PaStream *Stream{nullptr};
PaStreamParameters Params;
ALuint UpdateSize{0u};
+
+ ALCportPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCportPlayback_WriteCallback(const void *inputBuffer, void *outputBuffer,
@@ -158,8 +160,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCportPlayback);
void ALCportPlayback_Construct(ALCportPlayback *self, ALCdevice *device)
{
- new (self) ALCportPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCportPlayback{device};
SET_VTABLE2(ALCportPlayback, ALCbackend, self);
}
@@ -170,7 +171,6 @@ void ALCportPlayback_Destruct(ALCportPlayback *self)
ERR("Error closing stream: %s\n", Pa_GetErrorText(err));
self->Stream = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCportPlayback();
}
@@ -320,6 +320,8 @@ struct ALCportCapture final : public ALCbackend {
PaStreamParameters Params;
RingBufferPtr Ring{nullptr};
+
+ ALCportCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCportCapture_ReadCallback(const void *inputBuffer, void *outputBuffer,
@@ -344,8 +346,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCportCapture);
void ALCportCapture_Construct(ALCportCapture *self, ALCdevice *device)
{
- new (self) ALCportCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCportCapture{device};
SET_VTABLE2(ALCportCapture, ALCbackend, self);
}
@@ -356,7 +357,6 @@ void ALCportCapture_Destruct(ALCportCapture *self)
ERR("Error closing stream: %s\n", Pa_GetErrorText(err));
self->Stream = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCportCapture();
}
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 42fc267f..dc7f97b3 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -535,6 +535,8 @@ struct PulsePlayback final : public ALCbackend {
ALuint mBufferSize{0u};
ALuint mFrameSize{0u};
+
+ PulsePlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void PulsePlayback_deviceCallback(pa_context *context, const pa_sink_info *info, int eol, void *pdata);
@@ -570,8 +572,7 @@ DEFINE_ALCBACKEND_VTABLE(PulsePlayback);
void PulsePlayback_Construct(PulsePlayback *self, ALCdevice *device)
{
- new (self) PulsePlayback();
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) PulsePlayback{device};
SET_VTABLE2(PulsePlayback, ALCbackend, self);
}
@@ -584,7 +585,6 @@ void PulsePlayback_Destruct(PulsePlayback *self)
self->context = nullptr;
self->stream = nullptr;
}
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~PulsePlayback();
}
@@ -1182,6 +1182,8 @@ struct PulseCapture final : public ALCbackend {
pa_stream *stream{nullptr};
pa_context *context{nullptr};
+
+ PulseCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void PulseCapture_deviceCallback(pa_context *context, const pa_source_info *info, int eol, void *pdata);
@@ -1214,8 +1216,7 @@ DEFINE_ALCBACKEND_VTABLE(PulseCapture);
void PulseCapture_Construct(PulseCapture *self, ALCdevice *device)
{
- new (self) PulseCapture();
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) PulseCapture{device};
SET_VTABLE2(PulseCapture, ALCbackend, self);
}
@@ -1228,7 +1229,6 @@ void PulseCapture_Destruct(PulseCapture *self)
self->context = nullptr;
self->stream = nullptr;
}
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~PulseCapture();
}
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index f14718c0..ff74ff21 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -172,6 +172,8 @@ void deviceList(int type, al::vector<DevMap> *devmap)
/* Wrappers to use an old-style backend with the new interface. */
struct PlaybackWrapper final : public ALCbackend {
std::unique_ptr<qsa_data> ExtraData;
+
+ PlaybackWrapper(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device);
@@ -613,11 +615,8 @@ static void qsa_stop_playback(PlaybackWrapper *self)
static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device)
{
- new (self) PlaybackWrapper{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) PlaybackWrapper{device};
SET_VTABLE2(PlaybackWrapper, ALCbackend, self);
-
- self->ExtraData = NULL;
}
static void PlaybackWrapper_Destruct(PlaybackWrapper *self)
@@ -625,7 +624,6 @@ static void PlaybackWrapper_Destruct(PlaybackWrapper *self)
if(self->ExtraData)
qsa_close_playback(self);
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~PlaybackWrapper();
}
@@ -657,6 +655,8 @@ static void PlaybackWrapper_stop(PlaybackWrapper *self)
struct CaptureWrapper final : public ALCbackend {
std::unique_ptr<qsa_data> ExtraData;
+
+ CaptureWrapper(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device);
@@ -916,8 +916,7 @@ static ALCenum qsa_capture_samples(CaptureWrapper *self, ALCvoid *buffer, ALCuin
static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device)
{
- new (self) CaptureWrapper{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) CaptureWrapper{device};
SET_VTABLE2(CaptureWrapper, ALCbackend, self);
}
@@ -926,7 +925,6 @@ static void CaptureWrapper_Destruct(CaptureWrapper *self)
if(self->ExtraData)
qsa_close_capture(self);
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~CaptureWrapper();
}
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index d61e0a1b..75052b0f 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -40,13 +40,15 @@
#endif
struct ALCsdl2Backend final : public ALCbackend {
- SDL_AudioDeviceID deviceID;
- ALsizei frameSize;
+ SDL_AudioDeviceID deviceID{0u};
+ ALsizei frameSize{0};
- ALuint Frequency;
- DevFmtChannels FmtChans;
- DevFmtType FmtType;
- ALuint UpdateSize;
+ ALuint Frequency{0u};
+ DevFmtChannels FmtChans{};
+ DevFmtType FmtType{};
+ ALuint UpdateSize{0u};
+
+ ALCsdl2Backend(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static void ALCsdl2Backend_Construct(ALCsdl2Backend *self, ALCdevice *device);
@@ -68,11 +70,9 @@ static const ALCchar defaultDeviceName[] = DEVNAME_PREFIX "Default Device";
static void ALCsdl2Backend_Construct(ALCsdl2Backend *self, ALCdevice *device)
{
- new (self) ALCsdl2Backend{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCsdl2Backend{device};
SET_VTABLE2(ALCsdl2Backend, ALCbackend, self);
- self->deviceID = 0;
self->frameSize = device->frameSizeFromFmt();
self->Frequency = device->Frequency;
self->FmtChans = device->FmtChans;
@@ -86,7 +86,6 @@ static void ALCsdl2Backend_Destruct(ALCsdl2Backend *self)
SDL_CloseAudioDevice(self->deviceID);
self->deviceID = 0;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCsdl2Backend();
}
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index 027ff9f2..576e9ba9 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -47,6 +47,8 @@ struct SndioPlayback final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ SndioPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static int SndioPlayback_mixerProc(SndioPlayback *self);
@@ -69,8 +71,7 @@ DEFINE_ALCBACKEND_VTABLE(SndioPlayback);
static void SndioPlayback_Construct(SndioPlayback *self, ALCdevice *device)
{
- new (self) SndioPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) SndioPlayback{device};
SET_VTABLE2(SndioPlayback, ALCbackend, self);
}
@@ -83,7 +84,6 @@ static void SndioPlayback_Destruct(SndioPlayback *self)
al_free(self->mix_data);
self->mix_data = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~SndioPlayback();
}
@@ -283,6 +283,8 @@ struct SndioCapture final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ SndioCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static int SndioCapture_recordProc(SndioCapture *self);
@@ -305,8 +307,7 @@ DEFINE_ALCBACKEND_VTABLE(SndioCapture);
static void SndioCapture_Construct(SndioCapture *self, ALCdevice *device)
{
- new (self) SndioCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) SndioCapture{device};
SET_VTABLE2(SndioCapture, ALCbackend, self);
}
@@ -316,7 +317,6 @@ static void SndioCapture_Destruct(SndioCapture *self)
sio_close(self->sndHandle);
self->sndHandle = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~SndioCapture();
}
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index 41026de8..60db963b 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -54,6 +54,8 @@ struct ALCsolarisBackend final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCsolarisBackend(ALCdevice *device) noexcept : ALCbackend{device} { }
};
static int ALCsolarisBackend_mixerProc(ALCsolarisBackend *self);
@@ -81,8 +83,7 @@ static const char *solaris_driver = "/dev/audio";
static void ALCsolarisBackend_Construct(ALCsolarisBackend *self, ALCdevice *device)
{
- new (self) ALCsolarisBackend{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCsolarisBackend{device};
SET_VTABLE2(ALCsolarisBackend, ALCbackend, self);
}
@@ -96,7 +97,6 @@ static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self)
self->mix_data = nullptr;
self->data_size = 0;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCsolarisBackend();
}
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index a7524ce1..c7a216eb 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -491,6 +491,8 @@ DWORD CALLBACK WasapiProxy_messageHandler(void *ptr)
struct ALCwasapiPlayback final : public ALCbackend, WasapiProxy {
+ ALCwasapiPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
+
HRESULT openProxy() override;
void closeProxy() override;
@@ -533,9 +535,8 @@ DEFINE_ALCBACKEND_VTABLE(ALCwasapiPlayback);
void ALCwasapiPlayback_Construct(ALCwasapiPlayback *self, ALCdevice *device)
{
- new (self) ALCwasapiPlayback{};
+ new (self) ALCwasapiPlayback{device};
SET_VTABLE2(ALCwasapiPlayback, ALCbackend, self);
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
}
void ALCwasapiPlayback_Destruct(ALCwasapiPlayback *self)
@@ -558,7 +559,6 @@ void ALCwasapiPlayback_Destruct(ALCwasapiPlayback *self)
CloseHandle(self->mMsgEvent);
self->mMsgEvent = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCwasapiPlayback();
}
@@ -1154,6 +1154,8 @@ ClockLatency ALCwasapiPlayback_getClockLatency(ALCwasapiPlayback *self)
struct ALCwasapiCapture final : public ALCbackend, WasapiProxy {
+ ALCwasapiCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
+
HRESULT openProxy() override;
void closeProxy() override;
@@ -1198,9 +1200,8 @@ DEFINE_ALCBACKEND_VTABLE(ALCwasapiCapture);
void ALCwasapiCapture_Construct(ALCwasapiCapture *self, ALCdevice *device)
{
- new (self) ALCwasapiCapture{};
+ new (self) ALCwasapiCapture{device};
SET_VTABLE2(ALCwasapiCapture, ALCbackend, self);
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
}
void ALCwasapiCapture_Destruct(ALCwasapiCapture *self)
@@ -1220,7 +1221,6 @@ void ALCwasapiCapture_Destruct(ALCwasapiCapture *self)
CloseHandle(self->mNotifyEvent);
self->mNotifyEvent = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCwasapiCapture();
}
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index d40e93f0..3a65fc64 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -86,6 +86,8 @@ struct ALCwaveBackend final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCwaveBackend(ALCdevice *device) noexcept : ALCbackend{device} { }
};
int ALCwaveBackend_mixerProc(ALCwaveBackend *self);
@@ -108,8 +110,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCwaveBackend);
void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device)
{
- new (self) ALCwaveBackend{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCwaveBackend{device};
SET_VTABLE2(ALCwaveBackend, ALCbackend, self);
}
@@ -119,7 +120,6 @@ void ALCwaveBackend_Destruct(ALCwaveBackend *self)
fclose(self->mFile);
self->mFile = nullptr;
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCwaveBackend();
}
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index 485586f6..ab638cd4 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -132,6 +132,8 @@ struct ALCwinmmPlayback final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCwinmmPlayback(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void ALCwinmmPlayback_Construct(ALCwinmmPlayback *self, ALCdevice *device);
@@ -156,8 +158,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCwinmmPlayback);
void ALCwinmmPlayback_Construct(ALCwinmmPlayback *self, ALCdevice *device)
{
- new (self) ALCwinmmPlayback{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCwinmmPlayback{device};
SET_VTABLE2(ALCwinmmPlayback, ALCbackend, self);
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
@@ -172,7 +173,6 @@ void ALCwinmmPlayback_Destruct(ALCwinmmPlayback *self)
al_free(self->WaveBuffer[0].lpData);
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCwinmmPlayback();
}
@@ -407,6 +407,8 @@ struct ALCwinmmCapture final : public ALCbackend {
std::atomic<ALenum> mKillNow{AL_TRUE};
std::thread mThread;
+
+ ALCwinmmCapture(ALCdevice *device) noexcept : ALCbackend{device} { }
};
void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device);
@@ -431,8 +433,7 @@ DEFINE_ALCBACKEND_VTABLE(ALCwinmmCapture);
void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device)
{
- new (self) ALCwinmmCapture{};
- ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
+ new (self) ALCwinmmCapture{device};
SET_VTABLE2(ALCwinmmCapture, ALCbackend, self);
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
@@ -448,7 +449,6 @@ void ALCwinmmCapture_Destruct(ALCwinmmCapture *self)
al_free(self->WaveBuffer[0].lpData);
std::fill(self->WaveBuffer.begin(), self->WaveBuffer.end(), WAVEHDR{});
- ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
self->~ALCwinmmCapture();
}