aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-15 22:36:49 -0800
committerChris Robinson <[email protected]>2018-11-15 22:36:49 -0800
commit7884cec02b62605cbc046f2311bf3f3b35e20777 (patch)
tree6665addab5a2de4d7e617aa13abceef80c4f750c /Alc/backends
parent271cfcf8e31d06dca259a436251b70f5ffa882be (diff)
Convert the SndIO backend factory
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/sndio.cpp46
-rw-r--r--Alc/backends/sndio.h20
2 files changed, 31 insertions, 35 deletions
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index f1e678cf..691bdcde 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -20,6 +20,8 @@
#include "config.h"
+#include "backends/sndio.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,8 +31,6 @@
#include "threads.h"
#include "ringbuffer.h"
-#include "backends/base.h"
-
#include <sndio.h>
@@ -537,43 +537,19 @@ static ALCuint SndioCapture_availableSamples(SndioCapture *self)
}
-struct SndioBackendFactory final : public ALCbackendFactory {
- SndioBackendFactory() noexcept;
-};
-
-ALCbackendFactory *SndioBackendFactory_getFactory(void);
-
-static ALCboolean SndioBackendFactory_init(SndioBackendFactory *self);
-static DECLARE_FORWARD(SndioBackendFactory, ALCbackendFactory, void, deinit)
-static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory *self, ALCbackend_Type type);
-static void SndioBackendFactory_probe(SndioBackendFactory *self, enum DevProbe type, std::string *outnames);
-static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
-DEFINE_ALCBACKENDFACTORY_VTABLE(SndioBackendFactory);
-
-SndioBackendFactory::SndioBackendFactory() noexcept
- : ALCbackendFactory{GET_VTABLE2(SndioBackendFactory, ALCbackendFactory)}
-{ }
-
-ALCbackendFactory *SndioBackendFactory_getFactory(void)
+BackendFactory &SndIOBackendFactory::getFactory()
{
- static SndioBackendFactory factory{};
- return STATIC_CAST(ALCbackendFactory, &factory);
+ static SndIOBackendFactory factory{};
+ return factory;
}
-static ALCboolean SndioBackendFactory_init(SndioBackendFactory* UNUSED(self))
-{
- /* No dynamic loading */
- return ALC_TRUE;
-}
+bool SndIOBackendFactory::init()
+{ return true; }
-static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory* UNUSED(self), ALCbackend_Type type)
-{
- if(type == ALCbackend_Playback || type == ALCbackend_Capture)
- return ALC_TRUE;
- return ALC_FALSE;
-}
+bool SndIOBackendFactory::querySupport(ALCbackend_Type type)
+{ return (type == ALCbackend_Playback || type == ALCbackend_Capture); }
-static void SndioBackendFactory_probe(SndioBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames)
+void SndIOBackendFactory::probe(enum DevProbe type, std::string *outnames)
{
switch(type)
{
@@ -585,7 +561,7 @@ static void SndioBackendFactory_probe(SndioBackendFactory* UNUSED(self), enum De
}
}
-static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+ALCbackend *SndIOBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
{
diff --git a/Alc/backends/sndio.h b/Alc/backends/sndio.h
new file mode 100644
index 00000000..38cd2767
--- /dev/null
+++ b/Alc/backends/sndio.h
@@ -0,0 +1,20 @@
+#ifndef BACKENDS_SNDIO_H
+#define BACKENDS_SNDIO_H
+
+#include "backends/base.h"
+
+struct SndIOBackendFactory final : public BackendFactory {
+public:
+ bool init() override;
+ /*void deinit() override;*/
+
+ bool querySupport(ALCbackend_Type type) override;
+
+ void probe(enum DevProbe type, std::string *outnames) override;
+
+ ALCbackend *createBackend(ALCdevice *device, ALCbackend_Type type) override;
+
+ static BackendFactory &getFactory();
+};
+
+#endif /* BACKENDS_SNDIO_H */