Setting up slots on signals

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting up slots on signals

Russel Winder
I am trying to set up callbacks for the tuning signals of a DVB
pipeline in a playbin.

I have a call:

engine->set_tuning_callbacks(
        [](GstDvbSrc *, gpointer) { printf("Tuning started."); },
        [](GstDvbSrc *, gpointer) { printf("Tuning failed."); },
        [](GstDvbSrc *, gpointer) { printf("Tuning succeeded."); }
);

to the code:

void GStreamerEngine::set_tuning_callbacks(
        void (*start_callback)(GstDvbSrc *, gpointer),
        void (*failed_callback)(GstDvbSrc *, gpointer),
        void (*succeeded_callback)(GstDvbSrc *, gpointer)
) {
        g_assert(dvb_base_bin != nullptr);
        g_assert(start_callback != nullptr);
        g_assert(failed_callback != nullptr);
        g_assert(succeeded_callback != nullptr);
        g_signal_connect(dvb_base_bin, "tuning-start", G_CALLBACK(start_callback), nullptr);
        g_signal_connect(dvb_base_bin, "tuning-fail", G_CALLBACK(failed_callback), nullptr);
        g_signal_connect(dvb_base_bin, "tuning-done", G_CALLBACK(succeeded_callback), nullptr);
}

The value of dvb_base_bin is captured with:

void GStreamerEngine::on_source_created (GstElement * source, GstElement * pipe) {
        // Some other unrelated stuff here elided.
        dvb_base_bin = source;
        g_assert(dvb_base_bin != nullptr);
}

which is the callback for the "source-created" signal.

This appears to work, i.e. it compiles fine, and there are no failures
of the code to render DVB-T. However when executed, instead of the
messages from my callbacks, I appear to get:


(me-tv:20984): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(me-tv:20984): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(me-tv:20984): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(me-tv:20984): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(me-tv:20984): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(me-tv:20984): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed


I am not sure how to investigate this further to find out what is
actually happening, and why my callback are not being executed.

Setting GST_DEBUG=3 doesn't appear to provide any constructive data for
this issue.

Full code can be found at https://github.com/Me-TV/Me-TV


--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting up slots on signals

Sebastian Dröge-3
On So, 2016-03-27 at 10:39 +0100, Russel Winder wrote:

> I am trying to set up callbacks for the tuning signals of a DVB
> pipeline in a playbin.
> [...]
> g_signal_connect(dvb_base_bin, "tuning-start",
> G_CALLBACK(start_callback), nullptr);
> [...]
> dvb_base_bin = source;
> g_assert(dvb_base_bin != nullptr);

>
> (me-tv:20984): GLib-GObject-WARNING **: instance with invalid (NULL)
> class pointer
>
> (me-tv:20984): GLib-GObject-CRITICAL **: g_signal_connect_data:
> assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
This suggests that dvb_base_bin is not NULL (you check for that) but an
invalid pointer. Maybe you connect to the signals before source-setup
is called? Or you connect to the signals of the old dvbbasebin after
restarting playbin? It creates a new instance on every run, and you
don't take a strong reference there but just remember the reference
that is owned by playbin, so once playbin destroys it you'll have a
pointer pointing to some random memory.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting up slots on signals

Russel Winder
On Sun, 2016-03-27 at 13:39 +0300, Sebastian Dröge wrote:
[…]
> This suggests that dvb_base_bin is not NULL (you check for that) but
> an
> invalid pointer. Maybe you connect to the signals before source-setup
> is called? Or you connect to the signals of the old dvbbasebin after
> restarting playbin? It creates a new instance on every run, and you
> don't take a strong reference there but just remember the reference
> that is owned by playbin, so once playbin destroys it you'll have a
> pointer pointing to some random memory.

If you change the MRL of the playbin, does that lead to the destruction
of the extant pipeline and the creation of a brand new pipeline?

Oh, rats, I think I am calling stop rather than pause, which presumably
destroys the pipeline.

Is it better to let the playbin set up the dvbsrc rather than provide
an application constructed one and patch it into the pipeline?

--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting up slots on signals

Russel Winder
On Sun, 2016-03-27 at 14:21 +0100, Russel Winder wrote:
[…]
> If you change the MRL of the playbin, does that lead to the
> destruction
> of the extant pipeline and the creation of a brand new pipeline?

Experimental evidence seems to say yes, this is what happens.

As you can probably tell, I got the callbacks working :-)

> Oh, rats, I think I am calling stop rather than pause, which
> presumably
> destroys the pipeline.

This appears not to be an issue after all.

> Is it better to let the playbin set up the dvbsrc rather than provide
> an application constructed one and patch it into the pipeline?

I shall stick will leaving the playbin in control now that I have the
correct hooks to get the callbacks called.

--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting up slots on signals

Sebastian Dröge-3
In reply to this post by Russel Winder
On So, 2016-03-27 at 14:21 +0100, Russel Winder wrote:

> Is it better to let the playbin set up the dvbsrc rather than provide
> an application constructed one and patch it into the pipeline?

It's basically impossible to implant your own elements into playbin in
any sane way, other than those provided as property (sinks and
filters).

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Setting up slots on signals

Russel Winder
On Sun, 2016-03-27 at 19:17 +0300, Sebastian Dröge wrote:

> On So, 2016-03-27 at 14:21 +0100, Russel Winder wrote:
> >
> >  
> > Is it better to let the playbin set up the dvbsrc rather than
> > provide
> > an application constructed one and patch it into the pipeline?
> It's basically impossible to implant your own elements into playbin
> in
> any sane way, other than those provided as property (sinks and
> filters).
Turns out not to be a problem for my code now I have got the tuning
callbacks working: it turns out that everything necessary can happen in
the callback for source-setup signal.

--
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:[hidden email]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [hidden email]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (836 bytes) Download Attachment