Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.5 kB · 69 lines
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970package main
import ( "flag" "fmt" "log" "os" "runtime" "syscall" "time"
"github.com/go-gst/go-glib/glib" "github.com/go-gst/go-gst/gst")
// Demonstration of a GStreamer (or go-gst idk) leak
func main() { flag.Parse() if flag.NArg() != 1 { log.Fatal("expected 1 argument") } os.Setenv("GST_DEBUG", "leaks:9,GST_TRACER:9") os.Setenv("GST_TRACERS", "leaks") os.Setenv("GST_LEAKS_TRACER_SIG", "1") err := RunPipeline(flag.Arg(0)) if err != nil { log.Fatal(err) } runtime.GC() time.Sleep(1 * time.Second) process, err := os.FindProcess(os.Getpid()) if err != nil { log.Fatal(err) } if err := process.Signal(syscall.SIGUSR1); err != nil { log.Fatal(err) } time.Sleep(1 * time.Second)}
func RunPipeline(file string) error { gst.Init(nil) pipeline, err := gst.NewPipelineFromString(fmt.Sprintf("filesrc location=%s ! qtdemux ! fakesink", file)) if err != nil { return fmt.Errorf("failed to create pipeline: %w", err) }
mainLoop := glib.NewMainLoop(glib.MainContextDefault(), false) if err := pipeline.BlockSetState(gst.StatePlaying); err != nil { return fmt.Errorf("failed to set pipeline state: %w", err) }
pipeline.GetBus().AddWatch(func(msg *gst.Message) bool { if msg.Type() == gst.MessageEOS { mainLoop.Quit() return false } return true })
mainLoop.Run()
if err := pipeline.BlockSetState(gst.StateNull); err != nil { return fmt.Errorf("failed to set pipeline state: %w", err) }
return nil}