exp/audio/al: add more generic getters

Updates golang/go#13912.

Change-Id: I0eb017513872c9d44364b8c96e632ce3d08c6e10
Reviewed-on: https://go-review.googlesource.com/19472
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Burcu Dogan 2016-02-11 13:27:06 -08:00
parent 55a5a7b7a3
commit 77abf9cb27
3 changed files with 76 additions and 2 deletions

View File

@ -72,15 +72,31 @@ func Geti(param int) int32 {
return alGetInteger(param)
}
// Getf returns the float value of the given parameter.
// Getiv returns the int32 vector value of the given parameter.
func Getiv(param int, v []int32) {
alGetIntegerv(param, v)
}
// Getf returns the float32 value of the given parameter.
func Getf(param int) float32 {
return alGetFloat(param)
}
// Getfv returns the float32 vector value of the given parameter.
func Getfv(param int, v []float32) {
alGetFloatv(param, v[:])
}
// Getb returns the bool value of the given parameter.
func Getb(param int) bool {
return alGetBoolean(param)
}
// Getbv returns the bool vector value of the given parameter.
func Getbv(param int, v []bool) {
alGetBooleanv(param, v)
}
// GetString returns the string value of the given parameter.
func GetString(param int) string {
return alGetString(param)

View File

@ -45,7 +45,7 @@ ALint call_alGetInteger(LPALGETINTEGER fn, ALenum p) {
return fn(p);
}
void call_alGetFloatv(LPALGETFLOATV fn, ALenum p, const ALfloat* v) {
void call_alGetIntegerv(LPALGETINTEGERV fn, ALenum p, ALint* v) {
fn(p, v);
}
@ -53,6 +53,18 @@ ALfloat call_alGetFloat(LPALGETFLOAT fn, ALenum p) {
return fn(p);
}
void call_alGetFloatv(LPALGETFLOATV fn, ALenum p, ALfloat* v) {
fn(p, v);
}
ALboolean call_alGetBoolean(LPALGETBOOLEAN fn, ALenum p) {
return fn(p);
}
void call_alGetBooleanv(LPALGETBOOLEANV fn, ALenum p, ALboolean* v) {
fn(p, v);
}
const char* call_alGetString(LPALGETSTRING fn, ALenum p) {
return fn(p);
}
@ -184,8 +196,11 @@ var (
alDisableFunc C.LPALDISABLE
alIsEnabledFunc C.LPALISENABLED
alGetIntegerFunc C.LPALGETINTEGER
alGetIntegervFunc C.LPALGETINTEGERV
alGetFloatFunc C.LPALGETFLOAT
alGetFloatvFunc C.LPALGETFLOATV
alGetBooleanFunc C.LPALGETBOOLEAN
alGetBooleanvFunc C.LPALGETBOOLEANV
alGetStringFunc C.LPALGETSTRING
alDistanceModelFunc C.LPALDISTANCEMODEL
alDopplerFactorFunc C.LPALDOPPLERFACTOR
@ -240,8 +255,11 @@ func initAL() {
alDisableFunc = C.LPALDISABLE(fn("alDisable"))
alIsEnabledFunc = C.LPALISENABLED(fn("alIsEnabled"))
alGetIntegerFunc = C.LPALGETINTEGER(fn("alGetInteger"))
alGetIntegervFunc = C.LPALGETINTEGERV(fn("alGetIntegerv"))
alGetFloatFunc = C.LPALGETFLOAT(fn("alGetFloat"))
alGetFloatvFunc = C.LPALGETFLOATV(fn("alGetFloatv"))
alGetBooleanFunc = C.LPALGETBOOLEAN(fn("alGetBoolean"))
alGetBooleanvFunc = C.LPALGETBOOLEANV(fn("alGetBooleanv"))
alGetStringFunc = C.LPALGETSTRING(fn("alGetString"))
alDistanceModelFunc = C.LPALDISTANCEMODEL(fn("alDistanceModel"))
alDopplerFactorFunc = C.LPALDOPPLERFACTOR(fn("alDopplerFactor"))
@ -307,6 +325,10 @@ func alGetInteger(k int) int32 {
return int32(C.call_alGetInteger(alGetIntegerFunc, C.ALenum(k)))
}
func alGetIntegerv(k int, v []int32) {
C.call_alGetIntegerv(alGetIntegervFunc, C.ALenum(k), (*C.ALint)(unsafe.Pointer(&v[0])))
}
func alGetFloat(k int) float32 {
return float32(C.call_alGetFloat(alGetFloatFunc, C.ALenum(k)))
}
@ -315,6 +337,22 @@ func alGetFloatv(k int, v []float32) {
C.call_alGetFloatv(alGetFloatvFunc, C.ALenum(k), (*C.ALfloat)(unsafe.Pointer(&v[0])))
}
func alGetBoolean(k int) bool {
return C.call_alGetBoolean(alGetBooleanFunc, C.ALenum(k)) == C.AL_TRUE
}
func alGetBooleanv(k int, v []bool) {
val := make([]C.ALboolean, len(v))
for i, bv := range v {
if bv {
val[i] = C.AL_TRUE
} else {
val[i] = C.AL_FALSE
}
}
C.call_alGetBooleanv(alGetBooleanvFunc, C.ALenum(k), (*C.ALboolean)(unsafe.Pointer(&val[0])))
}
func alGetString(v int) string {
value := C.call_alGetString(alGetStringFunc, C.ALenum(v))
return C.GoString(value)

View File

@ -41,6 +41,10 @@ func alGetInteger(k int) int32 {
return int32(C.alGetInteger(C.ALenum(k)))
}
func alGetIntegerv(k int, v []int32) {
C.alGetIntegerv(C.ALenum(k), (*C.ALint)(unsafe.Pointer(&v[0])))
}
func alGetFloat(k int) float32 {
return float32(C.alGetFloat(C.ALenum(k)))
}
@ -49,6 +53,22 @@ func alGetFloatv(k int, v []float32) {
C.alGetFloatv(C.ALenum(k), (*C.ALfloat)(unsafe.Pointer(&v[0])))
}
func alGetBoolean(k int) bool {
return C.alGetBoolean(C.ALenum(k)) == C.AL_TRUE
}
func alGetBooleanv(k int, v []bool) {
val := make([]C.ALboolean, len(v))
for i, bv := range v {
if bv {
val[i] = C.AL_TRUE
} else {
val[i] = C.AL_FALSE
}
}
C.alGetBooleanv(C.ALenum(k), (*C.ALboolean)(unsafe.Pointer(&val[0])))
}
func alGetString(v int) string {
value := C.alGetString(C.ALenum(v))
return C.GoString((*C.char)(value))