diff --git a/go.mod b/go.mod index 8e8d860a0..a517a973e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( codeberg.org/gruf/go-debug v1.3.0 codeberg.org/gruf/go-errors/v2 v2.3.2 codeberg.org/gruf/go-fastcopy v1.1.2 - codeberg.org/gruf/go-ffmpreg v0.2.3 + codeberg.org/gruf/go-ffmpreg v0.2.4 codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf codeberg.org/gruf/go-kv v1.6.4 codeberg.org/gruf/go-list v0.0.0-20240425093752-494db03d641f diff --git a/go.sum b/go.sum index 706039b31..c86f215d9 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,8 @@ codeberg.org/gruf/go-fastcopy v1.1.2 h1:YwmYXPsyOcRBxKEE2+w1bGAZfclHVaPijFsOVOcn codeberg.org/gruf/go-fastcopy v1.1.2/go.mod h1:GDDYR0Cnb3U/AIfGM3983V/L+GN+vuwVMvrmVABo21s= codeberg.org/gruf/go-fastpath/v2 v2.0.0 h1:iAS9GZahFhyWEH0KLhFEJR+txx1ZhMXxYzu2q5Qo9c0= codeberg.org/gruf/go-fastpath/v2 v2.0.0/go.mod h1:3pPqu5nZjpbRrOqvLyAK7puS1OfEtQvjd6342Cwz56Q= -codeberg.org/gruf/go-ffmpreg v0.2.3 h1:6nKpR4KzAhyWHe5E1YatqogZUZbmCmUjwv6qST/P1Ks= -codeberg.org/gruf/go-ffmpreg v0.2.3/go.mod h1:oPMfBkOK7xmR/teT/dKW6SeMFpRos9ceR/OuUrxBfcQ= +codeberg.org/gruf/go-ffmpreg v0.2.4 h1:9NR0a5a0RjiIpyQgsqmHen6oadABADv04BWt7dr9kuE= +codeberg.org/gruf/go-ffmpreg v0.2.4/go.mod h1:oPMfBkOK7xmR/teT/dKW6SeMFpRos9ceR/OuUrxBfcQ= codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf h1:84s/ii8N6lYlskZjHH+DG6jyia8w2mXMZlRwFn8Gs3A= codeberg.org/gruf/go-iotools v0.0.0-20240710125620-934ae9c654cf/go.mod h1:zZAICsp5rY7+hxnws2V0ePrWxE0Z2Z/KXcN3p/RQCfk= codeberg.org/gruf/go-kv v1.6.4 h1:3NZiW8HVdBM3kpOiLb7XfRiihnzZWMAixdCznguhILk= diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpeg/ffmpeg.wasm b/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpeg/ffmpeg.wasm index a6f89abb7..5ab309072 100644 Binary files a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpeg/ffmpeg.wasm and b/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffmpeg/ffmpeg.wasm differ diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffprobe/ffprobe.wasm b/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffprobe/ffprobe.wasm index 7522d9472..d6f758b82 100644 Binary files a/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffprobe/ffprobe.wasm and b/vendor/codeberg.org/gruf/go-ffmpreg/embed/ffprobe/ffprobe.wasm differ diff --git a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/instance.go b/vendor/codeberg.org/gruf/go-ffmpreg/wasm/instance.go index 21a080ce9..7900ecd08 100644 --- a/vendor/codeberg.org/gruf/go-ffmpreg/wasm/instance.go +++ b/vendor/codeberg.org/gruf/go-ffmpreg/wasm/instance.go @@ -4,7 +4,6 @@ "context" "errors" "io" - "sync" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/sys" @@ -66,53 +65,6 @@ func (inst *Instantiator) New(ctx context.Context) (*Instance, error) { }, nil } -type InstancePool struct { - Instantiator - - pool []*Instance - lock sync.Mutex -} - -func (p *InstancePool) Get(ctx context.Context) (*Instance, error) { - for { - // Check for cached. - inst := p.Cached() - if inst == nil { - break - } - - // Check if closed. - if inst.IsClosed() { - continue - } - - return inst, nil - } - - // Must create new instance. - return p.Instantiator.New(ctx) -} - -func (p *InstancePool) Put(inst *Instance) { - if inst.inst != &p.Instantiator { - panic("instance and pool instantiators do not match") - } - p.lock.Lock() - p.pool = append(p.pool, inst) - p.lock.Unlock() -} - -func (p *InstancePool) Cached() *Instance { - var inst *Instance - p.lock.Lock() - if len(p.pool) > 0 { - inst = p.pool[len(p.pool)-1] - p.pool = p.pool[:len(p.pool)-1] - } - p.lock.Unlock() - return inst -} - // Instance ... // // NOTE: Instance is NOT concurrency @@ -153,18 +105,14 @@ func (inst *Instance) Run(ctx context.Context, args Args) (uint32, error) { // Instantiate the module from precompiled wasm module data. mod, err := inst.wzrt.InstantiateModule(ctx, inst.cmod, modcfg) - - if mod != nil { - // Close module. - mod.Close(ctx) - } - - // Check for a returned exit code error. - if err, ok := err.(*sys.ExitError); ok { + switch err := err.(type) { + case nil: + return 0, mod.Close(ctx) + case *sys.ExitError: return err.ExitCode(), nil + default: + return 0, err } - - return 0, err } func (inst *Instance) IsClosed() bool { diff --git a/vendor/modules.txt b/vendor/modules.txt index 48a0b0ef4..1e7e25dac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -30,7 +30,7 @@ codeberg.org/gruf/go-fastcopy # codeberg.org/gruf/go-fastpath/v2 v2.0.0 ## explicit; go 1.14 codeberg.org/gruf/go-fastpath/v2 -# codeberg.org/gruf/go-ffmpreg v0.2.3 +# codeberg.org/gruf/go-ffmpreg v0.2.4 ## explicit; go 1.22.0 codeberg.org/gruf/go-ffmpreg/embed/ffmpeg codeberg.org/gruf/go-ffmpreg/embed/ffprobe