mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 16:06:55 +08:00
finish AppSink impl and add example
This commit is contained in:
23
examples/common.go
Normal file
23
examples/common.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package examples
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tinyzimmer/go-gst/gst"
|
||||
)
|
||||
|
||||
// Run is used to wrap the given function in a main loop and print any error
|
||||
func Run(f func() error) {
|
||||
mainLoop := gst.NewMainLoop(gst.DefaultMainContext(), false)
|
||||
|
||||
defer mainLoop.Unref()
|
||||
|
||||
go func() {
|
||||
if err := f(); err != nil {
|
||||
fmt.Println("ERROR!", err)
|
||||
}
|
||||
mainLoop.Quit()
|
||||
}()
|
||||
|
||||
mainLoop.Run()
|
||||
}
|
Reference in New Issue
Block a user