Skip to content

Commit bebb75b

Browse files
authored
Merge pull request tinyzimmer#58 from go-gst/allow_nil_plugin
Allow nil plugin
2 parents aa872b0 + bea1b98 commit bebb75b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

gst/gst_element.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,17 @@ func ElementUnlinkMany(elems ...*Element) {
103103

104104
// RegisterElement creates a new elementfactory capable of instantiating objects of the given GoElement
105105
// and adds the factory to the plugin. A higher rank means more importance when autoplugging.
106+
//
107+
// plugin can also be nil to register a static element
106108
func RegisterElement(plugin *Plugin, name string, rank Rank, elem glib.GoObjectSubclass, extends glib.Extendable, interfaces ...glib.Interface) bool {
109+
var pluginref *C.GstPlugin
110+
111+
if plugin != nil {
112+
pluginref = plugin.Instance()
113+
}
114+
107115
return gobool(C.gst_element_register(
108-
plugin.Instance(),
116+
pluginref,
109117
C.CString(name),
110118
C.guint(rank),
111119
C.GType(glib.RegisterGoType(name, elem, extends, interfaces...)),

0 commit comments

Comments
 (0)