cleanup decodebin example

This commit is contained in:
tinyzimmer
2020-10-04 09:44:34 +03:00
parent 4017c9e6d0
commit a2f8ca9e50
2 changed files with 9 additions and 3 deletions

View File

@@ -135,8 +135,11 @@ func handleMessage(msg *gst.Message) error {
return nil
}
func runPipeline(pipeline *gst.Pipeline) error {
func runPipeline(loop *gst.MainLoop, pipeline *gst.Pipeline) error {
defer loop.Quit()
pipeline.SetState(gst.StatePlaying)
defer pipeline.Destroy()
bus := pipeline.GetPipelineBus()
@@ -165,6 +168,6 @@ func main() {
if err != nil {
return err
}
return runPipeline(pipeline)
return runPipeline(loop, pipeline)
})
}

View File

@@ -15,6 +15,7 @@ import "C"
import (
"errors"
"fmt"
"os"
"reflect"
"sync"
"unsafe"
@@ -67,7 +68,9 @@ func MarshalStructure(data interface{}) *Structure {
for i := 0; i < valsOf.NumField(); i++ {
gval := valsOf.Field(i).Interface()
fieldName := typeOf.Field(i).Name
st.SetValue(fieldName, gval)
if err := st.SetValue(fieldName, gval); err != nil {
fmt.Fprintf(os.Stderr, "Failed to set %v for %s", gval, fieldName)
}
}
return st
}