First thankyou for the handholding when I was out of my depth.
I am doing my preview and dynamic recording with 2 pipes intervideosink/src.
The system is working but I would like to log/respond to BOTH pipes. I add a callback (so far on 1 pipe)
// Create bus and add watch
GstBus *bus1 = gst_pipeline_get_bus (GST_PIPELINE (mainPipe));
gst_bus_add_signal_watch (bus1);
g_signal_connect (bus1, "message", G_CALLBACK (messageHandler), NULL);
Which unleaches a storm:
lots of same
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
(dvrPR:121489): GStreamer-CRITICAL **: 21:33:30.875: gst_mini_object_unref: assertion ‘GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0’ failed
malloc(): unsorted double linked list corrupted
Aborted (core dumped)
All caused by the g_signal_connect (…)
How would I set about trying to debug this. Is not the malloc/linked list bit indicative of a bug
slomo
October 1, 2024, 6:52am
2
Can you show the complete code, especially the messageHandler
callback?
#include <gst/gst.h>
GstElement *mainPipe;
GstElement *recordPipe;
static void messageHandler (GstBus *bus, GstMessage *msg, gpointer user_data)
{
GMainLoop *loop = (GMainLoop *)user_data;
GError *err;
gchar *debug_info;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &err, &debug_info);
g_printerr("----[error] %s\n", err->message);
g_printerr(" %s\n", debug_info ? debug_info : "none");
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_WARNING:
gst_message_parse_error (msg, &err, &debug_info);
g_printerr("----[warning] %s\n", err->message);
g_printerr(" %s\n", debug_info ? debug_info : "none");
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_INFO:
gst_message_parse_error (msg, &err, &debug_info);
g_printerr("----[info] %s\n", err->message);
g_printerr(" %s\n", debug_info ? debug_info : "none");
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_EOS:
g_print("----End-Of-Stream reached.\n");
//g_main_loop_quit(loop);
break;
default:
break;
}
gst_message_unref (msg);
}
int main(int argc, char *argv[]) {
// GstBus *bus;
// GMainLoop *loop1;
GstMessage *msg;
g_print ("--dvrRecord\n");
if (argc < 4) {
g_printerr ("usage: dvrPreview CardNo mainPipe recordPipe recordName\n");
// 0 1 2 3 4
exit (1);
}
// Initialize GStreamer
gst_init (&argc, &argv);
// Create pipelines
mainPipe = gst_pipeline_new ("mainPipe");
recordPipe = gst_pipeline_new ("recordPipe");
// Create pipeline from string
mainPipe = gst_parse_launch (argv[2], NULL);
recordPipe = gst_parse_launch (argv[3], NULL);
if (mainPipe == 0) {
g_printerr ("Failed to create mainPipe.\n");
return -1;
}
if (recordPipe == 0) {
g_printerr ("Failed to create recordPipe.\n");
return -1;
}
// Create bus and add watch
GstBus *bus1 = gst_pipeline_get_bus (GST_PIPELINE (mainPipe));
gst_bus_add_signal_watch (bus1);
g_signal_connect (bus1, "message", G_CALLBACK (messageHandler), NULL);
// Create main loop
GMainLoop *loop1 = g_main_loop_new (NULL, FALSE);
// Start pipeline
gst_element_set_state (mainPipe, GST_STATE_PLAYING);
// Run main loop
g_main_loop_run (loop1);
// Wait for EOS or error
//msg1 = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
// Free resources
//if (msg) {
// gst_message_unref (msg);
//}
gst_object_unref (bus1);
gst_object_unref (mainPipe);
g_main_loop_unref (loop1);
// Deinitialize GStreamer
gst_deinit();
return 0;
}
slomo
October 1, 2024, 2:10pm
4
Don’t unref the message at the end of your callback. You don’t own the reference
Thankyou, that makes sense! I’ll try