@@ -153,6 +153,8 @@ mlops_node_create (const gchar * name, const mlops_node_type_e type,
153
153
GError * err = NULL ;
154
154
GstStateChangeReturn ret ;
155
155
156
+ g_return_val_if_fail (id != NULL , - EINVAL );
157
+
156
158
switch (type ) {
157
159
case MLOPS_NODE_TYPE_PIPELINE :
158
160
{
@@ -173,9 +175,6 @@ mlops_node_create (const gchar * name, const mlops_node_type_e type,
173
175
desc , (err ) ? err -> message : "unknown reason" );
174
176
g_clear_error (& err );
175
177
176
- if (pipeline )
177
- gst_object_unref (pipeline );
178
-
179
178
result = - ESTRPIPE ;
180
179
goto error ;
181
180
}
@@ -186,12 +185,11 @@ mlops_node_create (const gchar * name, const mlops_node_type_e type,
186
185
ml_loge
187
186
("Failed to set the state of the pipeline to PAUSED. For the detail, please check the GStreamer log message." );
188
187
189
- gst_object_unref (pipeline );
190
188
result = - ESTRPIPE ;
191
189
goto error ;
192
190
}
193
191
194
- /* Add node info into hash table. */
192
+ /* Final step, add node info into hash table. */
195
193
node = g_new0 (mlops_node_s , 1 );
196
194
node -> type = type ;
197
195
node -> id = g_get_monotonic_time ();
@@ -204,12 +202,12 @@ mlops_node_create (const gchar * name, const mlops_node_type_e type,
204
202
g_hash_table_insert (g_mlops_node_table , GINT_TO_POINTER (node -> id ), node );
205
203
G_UNLOCK (mlops_node_table );
206
204
205
+ * id = node -> id ;
206
+
207
207
error :
208
- if (result == 0 ) {
209
- * id = node -> id ;
210
- } else {
211
- if (node )
212
- _mlops_node_free (node );
208
+ if (result != 0 ) {
209
+ if (pipeline )
210
+ gst_object_unref (pipeline );
213
211
}
214
212
215
213
g_free (desc );
0 commit comments