File: alc_android.go

package info (click to toggle)
golang-golang-x-mobile 0.0~git20250520.a1d9079%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,784 kB
  • sloc: objc: 1,512; java: 1,489; ansic: 1,159; xml: 365; asm: 34; sh: 14; makefile: 5
file content (76 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download
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
71
72
73
74
75
76
// 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.

package al

/*
#include <stdlib.h>
#include <dlfcn.h>
#include <AL/al.h>
#include <AL/alc.h>

ALCint call_alcGetError(LPALCGETERROR fn, ALCdevice* d) {
  return fn(d);
}

ALCdevice* call_alcOpenDevice(LPALCOPENDEVICE fn, const ALCchar* name) {
  return fn(name);
}

ALCboolean call_alcCloseDevice(LPALCCLOSEDEVICE fn, ALCdevice* d) {
  return fn(d);
}

ALCcontext* call_alcCreateContext(LPALCCREATECONTEXT fn, ALCdevice* d, const ALCint* attrs) {
  return fn(d, attrs);
}

ALCboolean call_alcMakeContextCurrent(LPALCMAKECONTEXTCURRENT fn, ALCcontext* c) {
  return fn(c);
}

void call_alcDestroyContext(LPALCDESTROYCONTEXT fn, ALCcontext* c) {
  return fn(c);
}
*/
import "C"
import (
	"sync"
	"unsafe"
)

var once sync.Once

func alcGetError(d unsafe.Pointer) int32 {
	dev := (*C.ALCdevice)(d)
	return int32(C.call_alcGetError(alcGetErrorFunc, dev))
}

func alcOpenDevice(name string) unsafe.Pointer {
	once.Do(initAL)
	n := C.CString(name)
	defer C.free(unsafe.Pointer(n))

	return (unsafe.Pointer)(C.call_alcOpenDevice(alcOpenDeviceFunc, (*C.ALCchar)(unsafe.Pointer(n))))
}

func alcCloseDevice(d unsafe.Pointer) bool {
	dev := (*C.ALCdevice)(d)
	return C.call_alcCloseDevice(alcCloseDeviceFunc, dev) == C.AL_TRUE
}

func alcCreateContext(d unsafe.Pointer, attrs []int32) unsafe.Pointer {
	dev := (*C.ALCdevice)(d)
	// TODO(jbd): Handle attrs.
	return (unsafe.Pointer)(C.call_alcCreateContext(alcCreateContextFunc, dev, nil))
}

func alcMakeContextCurrent(c unsafe.Pointer) bool {
	ctx := (*C.ALCcontext)(c)
	return C.call_alcMakeContextCurrent(alcMakeContextCurrentFunc, ctx) == C.AL_TRUE
}

func alcDestroyContext(c unsafe.Pointer) {
	C.call_alcDestroyContext(alcDestroyContextFunc, (*C.ALCcontext)(c))
}