Allow using a negative offset with callback buffers
[openal-soft.git] / al / extension.cpp
blob3ead0af82cb3db003e726ae63a506dc56c9be864
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
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 <cctype>
24 #include <cstdlib>
25 #include <cstring>
27 #include "AL/al.h"
28 #include "AL/alc.h"
30 #include "alc/context.h"
31 #include "alstring.h"
32 #include "core/except.h"
33 #include "opthelpers.h"
36 AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
37 START_API_FUNC
39 ContextRef context{GetContextRef()};
40 if(!context) UNLIKELY return AL_FALSE;
42 if(!extName) UNLIKELY
44 context->setError(AL_INVALID_VALUE, "NULL pointer");
45 return AL_FALSE;
48 size_t len{strlen(extName)};
49 const char *ptr{context->mExtensionList};
50 while(ptr && *ptr)
52 if(al::strncasecmp(ptr, extName, len) == 0 && (ptr[len] == '\0' || isspace(ptr[len])))
53 return AL_TRUE;
55 if((ptr=strchr(ptr, ' ')) != nullptr)
57 do {
58 ++ptr;
59 } while(isspace(*ptr));
63 return AL_FALSE;
65 END_API_FUNC
68 AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
69 START_API_FUNC
71 if(!funcName) return nullptr;
72 return alcGetProcAddress(nullptr, funcName);
74 END_API_FUNC
76 AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
77 START_API_FUNC
79 if(!enumName) return static_cast<ALenum>(0);
80 return alcGetEnumValue(nullptr, enumName);
82 END_API_FUNC