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