extension.cpp 2.3 KB

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