extension.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.
  8. *
  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.
  13. *
  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
  19. */
  20. #include "config.h"
  21. #include <string_view>
  22. #include "AL/al.h"
  23. #include "AL/alc.h"
  24. #include "alc/context.h"
  25. #include "alstring.h"
  26. #include "direct_defs.h"
  27. #include "opthelpers.h"
  28. AL_API DECL_FUNC1(ALboolean, alIsExtensionPresent, const ALchar*,extName)
  29. FORCE_ALIGN ALboolean AL_APIENTRY alIsExtensionPresentDirect(ALCcontext *context, const ALchar *extName) noexcept
  30. {
  31. if(!extName) UNLIKELY
  32. {
  33. context->setError(AL_INVALID_VALUE, "NULL pointer");
  34. return AL_FALSE;
  35. }
  36. const std::string_view tofind{extName};
  37. for(std::string_view ext : context->mExtensions)
  38. {
  39. if(al::case_compare(ext, tofind) == 0)
  40. return AL_TRUE;
  41. }
  42. return AL_FALSE;
  43. }
  44. AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName) noexcept
  45. {
  46. if(!funcName) return nullptr;
  47. return alcGetProcAddress(nullptr, funcName);
  48. }
  49. FORCE_ALIGN ALvoid* AL_APIENTRY alGetProcAddressDirect(ALCcontext*, const ALchar *funcName) noexcept
  50. {
  51. if(!funcName) return nullptr;
  52. return alcGetProcAddress(nullptr, funcName);
  53. }
  54. AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName) noexcept
  55. {
  56. if(!enumName) return ALenum{0};
  57. return alcGetEnumValue(nullptr, enumName);
  58. }
  59. FORCE_ALIGN ALenum AL_APIENTRY alGetEnumValueDirect(ALCcontext*, const ALchar *enumName) noexcept
  60. {
  61. if(!enumName) return ALenum{0};
  62. return alcGetEnumValue(nullptr, enumName);
  63. }