func createPool() {
	pool = &audioPool{
		sources:   [maxSources]al.Source{},
		available: []al.Source{},
		playing:   make(map[al.Source]*Source),
	}
	for i := 0; i < maxSources; i++ {
		pool.sources[i] = al.GenSources(1)[0]
		if al.Error() != 0 {
			break
		}
		pool.totalSources++
	}
	if pool.totalSources < 4 {
		panic("Could not generate audio sources.")
	}
	for i := 0; i < pool.totalSources; i++ {
		pool.available = append(pool.available, pool.sources[i])
	}
	go func() {
		ticker := time.NewTicker(1 * time.Second)
		go func() {
			for {
				select {
				case <-ticker.C:
					pool.update()
				}
			}
		}()
	}()
}
createPool generates a new pool and gets the max sources.
package openal
import (
	"sync"
	"time"
	"github.com/tanema/amore/audio/openal/al"
)
const maxSources = 64
var pool *audioPool
type audioPool struct {
	mutex        sync.Mutex
	totalSources int
	sources      [maxSources]al.Source
	available    []al.Source
	playing      map[al.Source]*Source
}
func init() {
	if err := al.OpenDevice(); err != nil {
		panic(err)
	}
}
func GetVolume() float32 { return al.ListenerGain() }
func SetVolume(gain float32) {
	al.SetListenerGain(gain)
}
func PauseAll() {
	for _, source := range pool.playing {
		source.Pause()
	}
}
func PlayAll() {
	for _, source := range pool.playing {
		source.Play()
	}
}
func RewindAll() {
	for _, source := range pool.playing {
		source.Rewind()
	}
}
func StopAll() {
	for _, source := range pool.playing {
		source.Stop()
	}
	pool.playing = make(map[al.Source]*Source)
}