Ejemplo n.º 1
0
func initSourceList() {
	for i, _ := range sourceList {
		C.alGenSources(1, &sourceList[i].id)
		sourceList[i].occupied = false
		sourceList[i].isPlaying = false
	}

	sourceChannel = make(chan int)
	go func() {
		var state C.ALint
		for {
			select {
			case _, ok := <-sourceChannel:
				if !ok {
					return
				}
			default:
				for i, src := range sourceList {
					if sourceList[i].occupied == true && sourceList[i].isPlaying == true {
						C.alGetSourcei(src.id, C.AL_SOURCE_STATE, &state)
						if state != C.AL_PLAYING {
							sourceList[i].occupied = false
							sourceList[i].isPlaying = false
						}
					}
				}
			}
		}
	}()
}
Ejemplo n.º 2
0
func GenSources(numSources int) ([]Source, error) {
	if numSources == 0 {
		return nil, nil // AL guarantees that 0 will have no effect, so we'll save ourselves the C call
	}
	buf := make([]Source, numSources)
	C.alGenSources(C.ALsizei(C.int(numSources)), (*C.ALuint)(unsafe.Pointer(&buf[0])))
	if err := GetError(); err != nil {
		return nil, err
	}

	return buf, nil
}
Ejemplo n.º 3
0
func alGenSources(n int) []Source {
	s := make([]Source, n)
	C.alGenSources(C.ALsizei(n), (*C.ALuint)(unsafe.Pointer(&s[0])))
	return s
}
Ejemplo n.º 4
0
Archivo: source.go Proyecto: nzlov/goal
func GenSources(sources []Source) {
	if len(sources) > 0 {
		C.alGenSources(C.ALsizei(len(sources)), (*C.ALuint)(&sources[0]))
	}
}
Ejemplo n.º 5
0
Archivo: source.go Proyecto: nzlov/goal
func GenSource() Source {
	var b C.ALuint
	C.alGenSources(1, &b)
	return Source(b)
}
Ejemplo n.º 6
0
// Not really any different from GenSources(1), except it returns a single buffer instead of a slice
func GenSource() (source Source, err error) {
	C.alGenSources(C.ALsizei(C.int(1)), &source.source)
	err = GetError()
	return
}