diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 6 | ||||
-rw-r--r-- | Alc/backends/coreaudio.cpp | 52 | ||||
-rw-r--r-- | Alc/backends/coreaudio.h | 20 |
3 files changed, 39 insertions, 39 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 52aab346..d4e2dda5 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -65,6 +65,9 @@ #ifdef HAVE_WASAPI #include "backends/wasapi.h" #endif +#ifdef HAVE_COREAUDIO +#include "backends/coreaudio.h" +#endif namespace { @@ -84,6 +87,9 @@ struct BackendInfo BackendList[] = { #ifdef HAVE_WASAPI { "wasapi", WasapiBackendFactory::getFactory }, #endif +#ifdef HAVE_COREAUDIO + { "core", CoreAudioBackendFactory::getFactory }, +#endif #if 0 { "jack", ALCjackBackendFactory_getFactory }, { "pulse", ALCpulseBackendFactory_getFactory }, diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp index 1a3f2ab1..62df982e 100644 --- a/Alc/backends/coreaudio.cpp +++ b/Alc/backends/coreaudio.cpp @@ -20,6 +20,8 @@ #include "config.h" +#include "backends/coreaudio.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -32,8 +34,6 @@ #include <AudioUnit/AudioUnit.h> #include <AudioToolbox/AudioToolbox.h> -#include "backends/base.h" - static const ALCchar ca_device[] = "CoreAudio Default"; @@ -753,44 +753,18 @@ static ALCuint ALCcoreAudioCapture_availableSamples(ALCcoreAudioCapture *self) } -struct ALCcoreAudioBackendFactory final : public ALCbackendFactory { - ALCcoreAudioBackendFactory() noexcept; -}; - -ALCbackendFactory *ALCcoreAudioBackendFactory_getFactory(void); - -static ALCboolean ALCcoreAudioBackendFactory_init(ALCcoreAudioBackendFactory *self); -static DECLARE_FORWARD(ALCcoreAudioBackendFactory, ALCbackendFactory, void, deinit) -static ALCboolean ALCcoreAudioBackendFactory_querySupport(ALCcoreAudioBackendFactory *self, ALCbackend_Type type); -static void ALCcoreAudioBackendFactory_probe(ALCcoreAudioBackendFactory *self, enum DevProbe type, std::string *outnames); -static ALCbackend* ALCcoreAudioBackendFactory_createBackend(ALCcoreAudioBackendFactory *self, ALCdevice *device, ALCbackend_Type type); -DEFINE_ALCBACKENDFACTORY_VTABLE(ALCcoreAudioBackendFactory); - - -ALCcoreAudioBackendFactory::ALCcoreAudioBackendFactory() noexcept - : ALCbackendFactory{GET_VTABLE2(ALCcoreAudioBackendFactory, ALCbackendFactory)} -{ } - -ALCbackendFactory *ALCcoreAudioBackendFactory_getFactory(void) +BackendFactory &CoreAudioBackendFactory::getFactory() { - static ALCcoreAudioBackendFactory factory{}; - return STATIC_CAST(ALCbackendFactory, &factory); + static CoreAudioBackendFactory factory{}; + return factory; } +bool CoreAudioBackendFactory::init() { return true; } -static ALCboolean ALCcoreAudioBackendFactory_init(ALCcoreAudioBackendFactory* UNUSED(self)) -{ - return ALC_TRUE; -} - -static ALCboolean ALCcoreAudioBackendFactory_querySupport(ALCcoreAudioBackendFactory* UNUSED(self), ALCbackend_Type type) -{ - if(type == ALCbackend_Playback || ALCbackend_Capture) - return ALC_TRUE; - return ALC_FALSE; -} +bool CoreAudioBackendFactory::querySupport(ALCbackend_Type type) +{ return (type == ALCbackend_Playback || ALCbackend_Capture); } -static void ALCcoreAudioBackendFactory_probe(ALCcoreAudioBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames) +void CoreAudioBackendFactory::probe(enum DevProbe type, std::string *outnames) { switch(type) { @@ -802,22 +776,22 @@ static void ALCcoreAudioBackendFactory_probe(ALCcoreAudioBackendFactory* UNUSED( } } -static ALCbackend* ALCcoreAudioBackendFactory_createBackend(ALCcoreAudioBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) +ALCbackend *CoreAudioBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type) { if(type == ALCbackend_Playback) { ALCcoreAudioPlayback *backend; NEW_OBJ(backend, ALCcoreAudioPlayback)(device); - if(!backend) return NULL; + if(!backend) return nullptr; return STATIC_CAST(ALCbackend, backend); } if(type == ALCbackend_Capture) { ALCcoreAudioCapture *backend; NEW_OBJ(backend, ALCcoreAudioCapture)(device); - if(!backend) return NULL; + if(!backend) return nullptr; return STATIC_CAST(ALCbackend, backend); } - return NULL; + return nullptr; } diff --git a/Alc/backends/coreaudio.h b/Alc/backends/coreaudio.h new file mode 100644 index 00000000..2926ee12 --- /dev/null +++ b/Alc/backends/coreaudio.h @@ -0,0 +1,20 @@ +#ifndef BACKENDS_COREAUDIO_H +#define BACKENDS_COREAUDIO_H + +#include "backends/base.h" + +struct CoreAudioBackendFactory 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_COREAUDIO_H */ |