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
on src_pad_buffer_probe()
thorough custom struct. But the program crashes unexpectedly. I am experimenting this for GTK and QT multi-threaded communication.
struct customData d;
went out of scope and was destructed at the time ofsrc_pad_buffer_probe()
call. It seems to be a simple C/C++ question. – Alexander Vg_signal_connect(G_OBJECT(src_pad), "src", G_CALLBACK(src_pad_buffer_probe), &d);
is correct or not? – neuroSparK