github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/mobile/exp/audio/al/alc_notandroid.go (about)

     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  
     5  // +build darwin linux,!android
     6  
     7  package al
     8  
     9  /*
    10  #cgo darwin   CFLAGS:  -DGOOS_darwin
    11  #cgo linux    CFLAGS:  -DGOOS_linux
    12  #cgo darwin   LDFLAGS: -framework OpenAL
    13  #cgo linux    LDFLAGS: -lopenal
    14  
    15  #ifdef GOOS_darwin
    16  #include <stdlib.h>
    17  #include <OpenAL/alc.h>
    18  #endif
    19  
    20  #ifdef GOOS_linux
    21  #include <stdlib.h>
    22  #include <AL/alc.h>
    23  #endif
    24  */
    25  import "C"
    26  import "unsafe"
    27  
    28  /*
    29  On Ubuntu 14.04 'Trusty', you may have to install these libraries:
    30  sudo apt-get install libopenal-dev
    31  */
    32  
    33  func alcGetError(d unsafe.Pointer) int32 {
    34  	dev := (*C.ALCdevice)(d)
    35  	return int32(C.alcGetError(dev))
    36  }
    37  
    38  func alcOpenDevice(name string) unsafe.Pointer {
    39  	n := C.CString(name)
    40  	defer C.free(unsafe.Pointer(n))
    41  
    42  	return (unsafe.Pointer)(C.alcOpenDevice((*C.ALCchar)(unsafe.Pointer(n))))
    43  }
    44  
    45  func alcCloseDevice(d unsafe.Pointer) bool {
    46  	dev := (*C.ALCdevice)(d)
    47  	return C.alcCloseDevice(dev) == C.ALC_TRUE
    48  }
    49  
    50  func alcCreateContext(d unsafe.Pointer, attrs []int32) unsafe.Pointer {
    51  	dev := (*C.ALCdevice)(d)
    52  	return (unsafe.Pointer)(C.alcCreateContext(dev, nil))
    53  }
    54  
    55  func alcMakeContextCurrent(c unsafe.Pointer) bool {
    56  	ctx := (*C.ALCcontext)(c)
    57  	return C.alcMakeContextCurrent(ctx) == C.ALC_TRUE
    58  }
    59  
    60  func alcDestroyContext(c unsafe.Pointer) {
    61  	C.alcDestroyContext((*C.ALCcontext)(c))
    62  }