GNOME Bugzilla – Bug 765078
Gst::Sample::get_caps doesn't reference the returned Glib::RefPtr<Gst::Caps>
Last modified: 2016-04-15 21:26:05 UTC
Hi, I was trying to get print out the caps of a sample of a Gst::AppSink to understand what it is giving me and I uncovered a bug (I think): In the slot for Gst::AppSink::signal_new_sample(): ``` using SamplePtr = Glib::RefPtr<Gst::Sample>; SamplePtr sample = m_app_sink->pull_sample(); ASSERT(sample); // Use the C++ API CapsPtr caps = sample->get_caps(); caps->reference(); ASSERT(caps); // Use the standard API // GstCaps* caps = gst_sample_get_caps(sample->gobj()); ``` In the C++ wrapped version, if caps->reference() is not used, then it crashes after 10 iterations or so because the object's ref count goes to zero eventually. If I add caps->reference(), then the ref count stays even. I think that the bug is in sample.hg where it's not marked as refreturn but I'm not sure. Cheers Ben
BTW, this is with gstreamermm 1.4.3 and gstreamer 1.6.3
Thanks for the report. I've fixed the problem in master. It will be available in gstreamermm 1.8, which I'm currently working on. https://git.gnome.org/browse/gstreamermm/commit/?id=1b3fb04a9e3cfe49a8e0f475b0a4046c19c17be9
Wow, awesome. Thank you. I'll start working from master soon. I have found a couple more issues of the same kind that I'll post up.