mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-04 23:52:55 +08:00
clean up a bit morer
This commit is contained in:
@@ -81,6 +81,19 @@ func createPipeline() (*gst.Pipeline, error) {
|
|||||||
return pipeline, nil
|
return pipeline, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleMessage(msg *gst.Message) error {
|
||||||
|
defer msg.Unref() // Messages are a good candidate for trying out runtime finalizers
|
||||||
|
|
||||||
|
switch msg.Type() {
|
||||||
|
case gst.MessageEOS:
|
||||||
|
return app.ErrEOS
|
||||||
|
case gst.MessageError:
|
||||||
|
return msg.ParseError()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func mainLoop(pipeline *gst.Pipeline) error {
|
func mainLoop(pipeline *gst.Pipeline) error {
|
||||||
|
|
||||||
defer pipeline.Destroy() // Will stop and unref the pipeline when this function returns
|
defer pipeline.Destroy() // Will stop and unref the pipeline when this function returns
|
||||||
@@ -97,16 +110,9 @@ func mainLoop(pipeline *gst.Pipeline) error {
|
|||||||
if msg == nil {
|
if msg == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch msg.Type() {
|
if err := handleMessage(msg); err != nil {
|
||||||
case gst.MessageEOS:
|
|
||||||
msg.Unref() // Messsages are a good candidate for trying out runtime finalizers
|
|
||||||
break
|
|
||||||
case gst.MessageError:
|
|
||||||
err := msg.ParseError()
|
|
||||||
msg.Unref()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msg.Unref()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user