Unsolved How to correctly pass QObject on a struct to GstPadProbe through gpointer user_data
-
I want to receive a custom struct of QObject through gpointer on a GstPadProbe callback. I have connected the callback function like this:
struct customData d; thread = new QThread(); d.worker = new Worker(); d.worker->moveToThread(thread); d.message = "message\n"; src_pad = gst_element_get_static_pad (osd, "src"); if (!src_pad) g_print ("Unable to get src pad\n"); else gst_pad_add_probe (src_pad, GST_PAD_PROBE_TYPE_BUFFER, src_pad_buffer_probe, NULL, NULL); g_signal_connect(G_OBJECT(src_pad), "src", G_CALLBACK(src_pad_buffer_probe), &d);
My callback function is a probe:
static GstPadProbeReturn src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data) { struct customData *custom = (struct customData *) u_data; g_print("Hello World!\n%s\n", custom->message); return GST_PAD_PROBE_OK; }
I have defined the struct as :
struct customData{ char *message; Worker *worker; };
I am trying to access the
custom->message
onsrc_pad_buffer_probe()
thorough custom struct. But the program crashes unexpectedly. I am experimenting this for GTK and QT multi-threaded communication. -
I would guess 'd' is no longer alive once src_pad_buffer_probe() is called.