aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/pulseaudio.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-01 23:52:53 -0700
committerChris Robinson <[email protected]>2018-11-01 23:52:53 -0700
commit66df771d96d98acdf7c31d0ca5729b06502ae7d0 (patch)
treebec7b19faf2bd574c715a348cde6641e5e1ec007 /Alc/backends/pulseaudio.cpp
parent7307c2d5aa4a5cae73f05451ddbc1c4dcc9fad20 (diff)
Make the polymorphism macros less hacky in C++
In particular, it relies on derived structs using C++-style inheritence. Any implementation's source that's converted to C++ will consequently need to make that change.
Diffstat (limited to 'Alc/backends/pulseaudio.cpp')
-rw-r--r--Alc/backends/pulseaudio.cpp69
1 files changed, 37 insertions, 32 deletions
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index b6f7940b..719205c4 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -532,9 +532,7 @@ std::vector<DevMap> CaptureDevices;
} // namespace
-struct PulsePlayback {
- DERIVE_FROM_TYPE(ALCbackend);
-
+struct PulsePlayback final : public ALCbackend {
std::string device_name;
pa_buffer_attr attr;
@@ -1241,9 +1239,7 @@ static void PulsePlayback_unlock(PulsePlayback *self)
}
-struct PulseCapture {
- DERIVE_FROM_TYPE(ALCbackend);
-
+struct PulseCapture final : public ALCbackend {
std::string device_name;
const void *cap_store{nullptr};
@@ -1744,20 +1740,25 @@ static void PulseCapture_unlock(PulseCapture *self)
}
-typedef struct ALCpulseBackendFactory {
- DERIVE_FROM_TYPE(ALCbackendFactory);
-} ALCpulseBackendFactory;
-#define ALCPULSEBACKENDFACTORY_INITIALIZER { GET_VTABLE2(ALCpulseBackendFactory, ALCbackendFactory) }
+struct PulseBackendFactory final : public ALCbackendFactory {
+ PulseBackendFactory() noexcept;
+};
+#define ALCPULSEBACKENDFACTORY_INITIALIZER GET_VTABLE2(PulseBackendFactory, ALCbackendFactory)
+
+static ALCboolean PulseBackendFactory_init(PulseBackendFactory *self);
+static void PulseBackendFactory_deinit(PulseBackendFactory *self);
+static ALCboolean PulseBackendFactory_querySupport(PulseBackendFactory *self, ALCbackend_Type type);
+static void PulseBackendFactory_probe(PulseBackendFactory *self, enum DevProbe type, al_string *outnames);
+static ALCbackend* PulseBackendFactory_createBackend(PulseBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
+DEFINE_ALCBACKENDFACTORY_VTABLE(PulseBackendFactory);
-static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory *self);
-static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory *self);
-static ALCboolean ALCpulseBackendFactory_querySupport(ALCpulseBackendFactory *self, ALCbackend_Type type);
-static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory *self, enum DevProbe type, al_string *outnames);
-static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
-DEFINE_ALCBACKENDFACTORY_VTABLE(ALCpulseBackendFactory);
+PulseBackendFactory::PulseBackendFactory() noexcept
+ : ALCbackendFactory{ALCPULSEBACKENDFACTORY_INITIALIZER}
+{
+}
-static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory* UNUSED(self))
+static ALCboolean PulseBackendFactory_init(PulseBackendFactory* UNUSED(self))
{
ALCboolean ret{ALC_FALSE};
@@ -1797,7 +1798,7 @@ static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory* UNUSED(sel
return ret;
}
-static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory* UNUSED(self))
+static void PulseBackendFactory_deinit(PulseBackendFactory* UNUSED(self))
{
PlaybackDevices.clear();
CaptureDevices.clear();
@@ -1809,14 +1810,14 @@ static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory* UNUSED(self))
/* PulseAudio doesn't like being CloseLib'd sometimes */
}
-static ALCboolean ALCpulseBackendFactory_querySupport(ALCpulseBackendFactory* UNUSED(self), ALCbackend_Type type)
+static ALCboolean PulseBackendFactory_querySupport(PulseBackendFactory* UNUSED(self), ALCbackend_Type type)
{
if(type == ALCbackend_Playback || type == ALCbackend_Capture)
return ALC_TRUE;
return ALC_FALSE;
}
-static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), enum DevProbe type, al_string *outnames)
+static void PulseBackendFactory_probe(PulseBackendFactory* UNUSED(self), enum DevProbe type, al_string *outnames)
{
auto add_device = [outnames](const DevMap &entry) -> void
{
@@ -1841,7 +1842,7 @@ static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), e
}
}
-static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+static ALCbackend* PulseBackendFactory_createBackend(PulseBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
{
@@ -1866,40 +1867,44 @@ static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory*
#warning "Unsupported API version, backend will be unavailable!"
-typedef struct ALCpulseBackendFactory {
- DERIVE_FROM_TYPE(ALCbackendFactory);
-} ALCpulseBackendFactory;
-#define ALCPULSEBACKENDFACTORY_INITIALIZER { GET_VTABLE2(ALCpulseBackendFactory, ALCbackendFactory) }
+struct PulseBackendFactory final : public ALCbackendFactory {
+ PulseBackendFactory() noexcept;
+};
+#define ALCPULSEBACKENDFACTORY_INITIALIZER GET_VTABLE2(PulseBackendFactory, ALCbackendFactory)
-static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory* UNUSED(self))
+static ALCboolean PulseBackendFactory_init(PulseBackendFactory* UNUSED(self))
{
return ALC_FALSE;
}
-static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory* UNUSED(self))
+static void PulseBackendFactory_deinit(PulseBackendFactory* UNUSED(self))
{
}
-static ALCboolean ALCpulseBackendFactory_querySupport(ALCpulseBackendFactory* UNUSED(self), ALCbackend_Type UNUSED(type))
+static ALCboolean PulseBackendFactory_querySupport(PulseBackendFactory* UNUSED(self), ALCbackend_Type UNUSED(type))
{
return ALC_FALSE;
}
-static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), enum DevProbe UNUSED(type), al_string* UNUSED(outnames))
+static void PulseBackendFactory_probe(PulseBackendFactory* UNUSED(self), enum DevProbe UNUSED(type), al_string* UNUSED(outnames))
{
}
-static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory* UNUSED(self), ALCdevice* UNUSED(device), ALCbackend_Type UNUSED(type))
+static ALCbackend* PulseBackendFactory_createBackend(PulseBackendFactory* UNUSED(self), ALCdevice* UNUSED(device), ALCbackend_Type UNUSED(type))
{
return nullptr;
}
-DEFINE_ALCBACKENDFACTORY_VTABLE(ALCpulseBackendFactory);
+DEFINE_ALCBACKENDFACTORY_VTABLE(PulseBackendFactory);
+
+PulseBackendFactory::PulseBackendFactory() noexcept
+ : ALCbackendFactory{ALCPULSEBACKENDFACTORY_INITIALIZER}
+{ }
#endif /* PA_API_VERSION == 12 */
ALCbackendFactory *ALCpulseBackendFactory_getFactory(void)
{
- static ALCpulseBackendFactory factory{ALCPULSEBACKENDFACTORY_INITIALIZER};
+ static PulseBackendFactory factory{};
return STATIC_CAST(ALCbackendFactory, &factory);
}