VideoTools/vendor/github.com/ebitengine/purego
Stu Leak 68df790d27 Fix player frame generation and video playback
Major improvements to UnifiedPlayer:

1. GetFrameImage() now works when paused for responsive UI updates
2. Play() method properly starts FFmpeg process
3. Frame display loop runs continuously for smooth video display
4. Disabled audio temporarily to fix video playback fundamentals
5. Simplified FFmpeg command to focus on video stream only

Player now:
- Generates video frames correctly
- Shows video when paused
- Has responsive progress tracking
- Starts playback properly

Next steps: Re-enable audio playback once video is stable
2026-01-07 22:20:00 -05:00
..
internal Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
.gitignore Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
abi_amd64.h Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
abi_arm64.h Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
abi_loong64.h Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
cgo.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlerror.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_android.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_darwin.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_freebsd.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_linux.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_netbsd.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_nocgo_freebsd.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_nocgo_linux.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_nocgo_netbsd.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_playground.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn_stubs.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
dlfcn.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
func.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
gen.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
go_runtime.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
is_ios.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
LICENSE Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
nocgo.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
README.md Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
struct_amd64.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
struct_arm64.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
struct_loong64.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
struct_other.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
sys_amd64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
sys_arm64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
sys_loong64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
sys_unix_arm64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
sys_unix_loong64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
syscall_cgo_linux.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
syscall_sysv.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
syscall_windows.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
syscall.go Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
zcallback_amd64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
zcallback_arm64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00
zcallback_loong64.s Fix player frame generation and video playback 2026-01-07 22:20:00 -05:00

purego

Go Reference

A library for calling C functions from Go without Cgo.

This is beta software so expect bugs and potentially API breaking changes but each release will be tagged to avoid breaking people's code. Bug reports are encouraged.

Motivation

The Ebitengine game engine was ported to use only Go on Windows. This enabled cross-compiling to Windows from any other operating system simply by setting GOOS=windows. The purego project was born to bring that same vision to the other platforms supported by Ebitengine.

Benefits

  • Simple Cross-Compilation: No C means you can build for other platforms easily without a C compiler.
  • Faster Compilation: Efficiently cache your entirely Go builds.
  • Smaller Binaries: Using Cgo generates a C wrapper function for each C function called. Purego doesn't!
  • Dynamic Linking: Load symbols at runtime and use it as a plugin system.
  • Foreign Function Interface: Call into other languages that are compiled into shared objects.
  • Cgo Fallback: Works even with CGO_ENABLED=1 so incremental porting is possible. This also means unsupported GOARCHs (freebsd/riscv64, linux/mips, etc.) will still work except for float arguments and return values.

Supported Platforms

Tier 1

Tier 1 platforms are the primary targets officially supported by PureGo. When a new version of PureGo is released, any critical bugs found on Tier 1 platforms are treated as release blockers. The release will be postponed until such issues are resolved.

  • Android: amd64, arm64
  • iOS: amd64, arm64
  • Linux: amd64, arm64
  • macOS: amd64, arm64
  • Windows: amd64, arm64

Tier 2

Tier 2 platforms are supported by PureGo on a best-effort basis. Critical bugs on Tier 2 platforms do not block new PureGo releases. However, fixes contributed by external contributors are very welcome and encouraged.

  • Android: 386, arm
  • FreeBSD: amd64, arm64
  • Linux: 386, arm, loong64
  • Windows: 386*, arm*

* These architectures only support SyscallN and NewCallback

Example

The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can be seen in the complete example at examples/libc which supports FreeBSD and Windows.

package main

import (
	"fmt"
	"runtime"

	"github.com/ebitengine/purego"
)

func getSystemLibrary() string {
	switch runtime.GOOS {
	case "darwin":
		return "/usr/lib/libSystem.B.dylib"
	case "linux":
		return "libc.so.6"
	default:
		panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS))
	}
}

func main() {
	libc, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL)
	if err != nil {
		panic(err)
	}
	var puts func(string)
	purego.RegisterLibFunc(&puts, libc, "puts")
	puts("Calling C from Go without Cgo!")
}

Then to run: CGO_ENABLED=0 go run main.go

Questions

If you have questions about how to incorporate purego in your project or want to discuss how it works join the Discord!

External Code

Purego uses code that originates from the Go runtime. These files are under the BSD-3 License that can be found in the Go Source. This is a list of the copied files:

  • abi_*.h from package runtime/cgo
  • wincallback.go from package runtime
  • zcallback_darwin_*.s from package runtime
  • internal/fakecgo/abi_*.h from package runtime/cgo
  • internal/fakecgo/asm_GOARCH.s from package runtime/cgo
  • internal/fakecgo/callbacks.go from package runtime/cgo
  • internal/fakecgo/go_GOOS_GOARCH.go from package runtime/cgo
  • internal/fakecgo/iscgo.go from package runtime/cgo
  • internal/fakecgo/setenv.go from package runtime/cgo
  • internal/fakecgo/freebsd.go from package runtime/cgo
  • internal/fakecgo/netbsd.go from package runtime/cgo

The files abi_*.h and internal/fakecgo/abi_*.h are the same because Bazel does not support cross-package use of #include so we need each one once per package. (cf. issue)