mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-04 15:42:52 +08:00
custom event example
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user