alc_notandroid.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build darwin || (linux && !android) || windows
  5. package al
  6. /*
  7. #cgo darwin CFLAGS: -DGOOS_darwin
  8. #cgo linux CFLAGS: -DGOOS_linux
  9. #cgo windows CFLAGS: -DGOOS_windows
  10. #cgo darwin LDFLAGS: -framework OpenAL
  11. #cgo linux LDFLAGS: -lopenal
  12. #cgo windows LDFLAGS: -lOpenAL32
  13. #ifdef GOOS_darwin
  14. #include <stdlib.h>
  15. #include <OpenAL/alc.h>
  16. #endif
  17. #ifdef GOOS_linux
  18. #include <stdlib.h>
  19. #include <AL/alc.h>
  20. #endif
  21. #ifdef GOOS_windows
  22. #include <windows.h>
  23. #include <stdlib.h>
  24. #include <AL/alc.h>
  25. #endif
  26. */
  27. import "C"
  28. import "unsafe"
  29. /*
  30. On Ubuntu 14.04 'Trusty', you may have to install these libraries:
  31. sudo apt-get install libopenal-dev
  32. */
  33. func alcGetError(d unsafe.Pointer) int32 {
  34. dev := (*C.ALCdevice)(d)
  35. return int32(C.alcGetError(dev))
  36. }
  37. func alcOpenDevice(name string) unsafe.Pointer {
  38. n := C.CString(name)
  39. defer C.free(unsafe.Pointer(n))
  40. return (unsafe.Pointer)(C.alcOpenDevice((*C.ALCchar)(unsafe.Pointer(n))))
  41. }
  42. func alcCloseDevice(d unsafe.Pointer) bool {
  43. dev := (*C.ALCdevice)(d)
  44. return C.alcCloseDevice(dev) == C.ALC_TRUE
  45. }
  46. func alcCreateContext(d unsafe.Pointer, attrs []int32) unsafe.Pointer {
  47. dev := (*C.ALCdevice)(d)
  48. return (unsafe.Pointer)(C.alcCreateContext(dev, nil))
  49. }
  50. func alcMakeContextCurrent(c unsafe.Pointer) bool {
  51. ctx := (*C.ALCcontext)(c)
  52. return C.alcMakeContextCurrent(ctx) == C.ALC_TRUE
  53. }
  54. func alcDestroyContext(c unsafe.Pointer) {
  55. C.alcDestroyContext((*C.ALCcontext)(c))
  56. }