custom event example

This commit is contained in:
tinyzimmer
2020-10-03 21:34:39 +03:00
parent a7aee670f9
commit c17e48f52e
4 changed files with 229 additions and 15 deletions

View File

@@ -21,3 +21,14 @@ func Run(f func() error) {
mainLoop.Run()
}
// RunLoop is used to wrap the given function in a main loop and print any error.
// The main loop itself is passed to the function for more control over exiting.
func RunLoop(f func(*gst.MainLoop) error) {
mainLoop := gst.NewMainLoop(gst.DefaultMainContext(), false)
defer mainLoop.Unref()
if err := f(mainLoop); err != nil {
fmt.Println("ERROR!", err)
}
}