Example #1
0
func NewFileStore(info *InfoDict, storePath string) (f FileStore, totalSize int64, err error) {
	C.Init()
	fs := new(fileStore)
	numFiles := len(info.Files)
	if numFiles == 0 {
		// Create dummy Files structure.
		info = &InfoDict{Files: []FileDict{FileDict{info.Length, []string{info.Name}, info.Md5sum}}}
		numFiles = 1
	}
	fs.files = make([]fileEntry, numFiles)
	fs.offsets = make([]int64, numFiles)
	for i, _ := range info.Files {
		src := &info.Files[i]
		fullPath := path.Join(storePath, path.Clean(path.Join(src.Path...)))
		err = ensureDirectory(fullPath)
		if err != nil {
			return
		}
		err = fs.files[i].open(fullPath, src.Length)
		if err != nil {
			return
		}
		fs.offsets[i] = totalSize
		totalSize += src.Length
	}
	f = fs
	return
}
Example #2
0
func main() {
	tick := time.Tick(time.Duration(16) * time.Millisecond)
	C.Init()
	lastSwap := C.SwapCount()
	noise := ReadSeekCloser{bytes.NewReader(MustAsset("sound/noise.wav"))}
	player, err := audio.NewPlayer(noise, audio.Mono16, 44100)
	if err != nil {
		log.Fatal(err)
	}
	player.SetVolume(1.0)
	for _ = range tick {
		swap := C.SwapCount()
		if swap != lastSwap {
			fmt.Println("swap count:", swap)
			state := player.State()
			if state == audio.Playing || state == audio.Paused {
				player.Stop()
			}
			player.Seek(0)
			player.Play()
			lastSwap = swap
		}
	}
}
Example #3
0
// Call after runtime.LockOSThread(), *NOT* in an init function
func (osx *osxSystemObject) Startup() {
	C.Init()
}
Example #4
0
func (t SystemTray) Init() {
	C.Init(t.ptr)
}
Example #5
0
func (i SystemTray) Init() {
	C.Init(i.ptr)
}
func init() {
	C.Init()
}
Example #7
0
func (b *Backend) Init(w, h int) {
	b.w = w
	b.h = h
	r := C.Init(C.int(w), C.int(h))
	b.r = r
}