Convert the SndIO backend factory
This commit is contained in:
parent
271cfcf8e3
commit
7884cec02b
@ -80,6 +80,9 @@
|
||||
#ifdef HAVE_SOLARIS
|
||||
#include "backends/solaris.h"
|
||||
#endif
|
||||
#ifdef HAVE_SNDIO
|
||||
#include "backends/sndio.h"
|
||||
#endif
|
||||
#ifdef HAVE_SDL2
|
||||
#include "backends/sdl2.h"
|
||||
#endif
|
||||
@ -120,9 +123,11 @@ struct BackendInfo BackendList[] = {
|
||||
#ifdef HAVE_SOLARIS
|
||||
{ "solaris", SolarisBackendFactory::getFactory },
|
||||
#endif
|
||||
#ifdef HAVE_SNDIO
|
||||
{ "sndio", SndIOBackendFactory::getFactory },
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
{ "sndio", SndioBackendFactory_getFactory },
|
||||
{ "oss", ALCossBackendFactory_getFactory },
|
||||
{ "qsa", ALCqsaBackendFactory_getFactory },
|
||||
{ "dsound", ALCdsoundBackendFactory_getFactory },
|
||||
|
@ -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)
|
||||
{
|
||||
|
20
Alc/backends/sndio.h
Normal file
20
Alc/backends/sndio.h
Normal file
@ -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 */
|
@ -1056,7 +1056,7 @@ IF(SOUNDIO_FOUND)
|
||||
IF(ALSOFT_BACKEND_SNDIO)
|
||||
SET(HAVE_SNDIO 1)
|
||||
SET(BACKENDS "${BACKENDS} SndIO (linked),")
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp Alc/backends/sndio.h)
|
||||
SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
|
||||
SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
|
||||
ENDIF()
|
||||
|
Loading…
x
Reference in New Issue
Block a user