Fix default effect initialization
[openal-soft.git] / Alc / backends / loopback.c
blob8f23aad9ff7b272c336f475086f01f6416d172bb
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 2011 by Chris Robinson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #include "config.h"
23 #include <stdlib.h>
25 #include "alMain.h"
26 #include "alu.h"
28 #include "backends/base.h"
31 typedef struct ALCloopback {
32 DERIVE_FROM_TYPE(ALCbackend);
33 } ALCloopback;
35 static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device);
36 static DECLARE_FORWARD(ALCloopback, ALCbackend, void, Destruct)
37 static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name);
38 static void ALCloopback_close(ALCloopback *self);
39 static ALCboolean ALCloopback_reset(ALCloopback *self);
40 static ALCboolean ALCloopback_start(ALCloopback *self);
41 static void ALCloopback_stop(ALCloopback *self);
42 static DECLARE_FORWARD2(ALCloopback, ALCbackend, ALCenum, captureSamples, void*, ALCuint)
43 static DECLARE_FORWARD(ALCloopback, ALCbackend, ALCuint, availableSamples)
44 static DECLARE_FORWARD(ALCloopback, ALCbackend, ClockLatency, getClockLatency)
45 static DECLARE_FORWARD(ALCloopback, ALCbackend, void, lock)
46 static DECLARE_FORWARD(ALCloopback, ALCbackend, void, unlock)
47 DECLARE_DEFAULT_ALLOCATORS(ALCloopback)
48 DEFINE_ALCBACKEND_VTABLE(ALCloopback);
51 static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device)
53 ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
54 SET_VTABLE2(ALCloopback, ALCbackend, self);
58 static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name)
60 ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
62 alstr_copy_cstr(&device->DeviceName, name);
63 return ALC_NO_ERROR;
66 static void ALCloopback_close(ALCloopback* UNUSED(self))
70 static ALCboolean ALCloopback_reset(ALCloopback *self)
72 SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice);
73 return ALC_TRUE;
76 static ALCboolean ALCloopback_start(ALCloopback* UNUSED(self))
78 return ALC_TRUE;
81 static void ALCloopback_stop(ALCloopback* UNUSED(self))
86 typedef struct ALCloopbackFactory {
87 DERIVE_FROM_TYPE(ALCbackendFactory);
88 } ALCloopbackFactory;
89 #define ALCNULLBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCloopbackFactory, ALCbackendFactory) } }
91 ALCbackendFactory *ALCloopbackFactory_getFactory(void);
92 static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory *self);
93 static DECLARE_FORWARD(ALCloopbackFactory, ALCbackendFactory, void, deinit)
94 static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory *self, ALCbackend_Type type);
95 static void ALCloopbackFactory_probe(ALCloopbackFactory *self, enum DevProbe type);
96 static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory *self, ALCdevice *device, ALCbackend_Type type);
97 DEFINE_ALCBACKENDFACTORY_VTABLE(ALCloopbackFactory);
100 ALCbackendFactory *ALCloopbackFactory_getFactory(void)
102 static ALCloopbackFactory factory = ALCNULLBACKENDFACTORY_INITIALIZER;
103 return STATIC_CAST(ALCbackendFactory, &factory);
106 static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory* UNUSED(self))
108 return ALC_TRUE;
111 static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory* UNUSED(self), ALCbackend_Type type)
113 if(type == ALCbackend_Loopback)
114 return ALC_TRUE;
115 return ALC_FALSE;
118 static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum DevProbe UNUSED(type))
122 static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
124 if(type == ALCbackend_Loopback)
126 ALCloopback *backend;
127 NEW_OBJ(backend, ALCloopback)(device);
128 if(!backend) return NULL;
129 return STATIC_CAST(ALCbackend, backend);
132 return NULL;