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