From 420599f8e37c8657fd1568aca3bcd5d1d4711234 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 23 Apr 2014 02:18:07 -0700 Subject: Avoid using assert() in createBackend --- Alc/backends/loopback.c | 17 ++++++++++------- Alc/backends/null.c | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'Alc/backends') diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.c index d509313a..505dfacf 100644 --- a/Alc/backends/loopback.c +++ b/Alc/backends/loopback.c @@ -121,15 +121,18 @@ static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum DevP static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) { - ALCloopback *backend; + if(type == ALCbackend_Loopback) + { + ALCloopback *backend; - assert(type == ALCbackend_Loopback); + backend = ALCloopback_New(sizeof(*backend)); + if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); - backend = ALCloopback_New(sizeof(*backend)); - if(!backend) return NULL; - memset(backend, 0, sizeof(*backend)); + ALCloopback_Construct(backend, device); - ALCloopback_Construct(backend, device); + return STATIC_CAST(ALCbackend, backend); + } - return STATIC_CAST(ALCbackend, backend); + return NULL; } diff --git a/Alc/backends/null.c b/Alc/backends/null.c index 2c13a80f..c5a4c15f 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -212,15 +212,18 @@ static void ALCnullBackendFactory_probe(ALCnullBackendFactory* UNUSED(self), enu static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) { - ALCnullBackend *backend; + if(type == ALCbackend_Playback) + { + ALCnullBackend *backend; - assert(type == ALCbackend_Playback); + backend = ALCnullBackend_New(sizeof(*backend)); + if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); - backend = ALCnullBackend_New(sizeof(*backend)); - if(!backend) return NULL; - memset(backend, 0, sizeof(*backend)); + ALCnullBackend_Construct(backend, device); - ALCnullBackend_Construct(backend, device); + return STATIC_CAST(ALCbackend, backend); + } - return STATIC_CAST(ALCbackend, backend); + return NULL; } -- cgit v1.2.3