GNOME Bugzilla – Bug 751606
audiobasesrc, audiobasesink: incorrect ringbuffer refcount when create_ringbuffer returns a non-floating ref
Last modified: 2018-11-03 11:38:58 UTC
gst_audio_base_{src,sink}_create_ringbuffer() calls the virtual function create_ringbuffer() to get a GstAudioRingBuffer, sets its parent to the GstAudioBase{Src,Sink} and returns a pointer to the ringbuffer without passing the reference (transfer none). When create_ringbuffer() virtual function returns a floating ref (which is done by the default implementation in GstAudio{Src,Sink}), everything is fine, as the floating ref is consumed by gst_object_ref_sink() in gst_object_set_parent() and the "unfloated" ref is stored in the Src/Sink object. However, when create_ringbuffer() virtual function returns a non-floating ref, the gst_object_ref_sink() inside gst_object_set_parent() increments the refcount which is wrong. For example, if the create_ringbuffer() vfunc returned object with refcount = 1, the gst_audio_base_{src,sink}_create_ringbuffer() returns the object with refcount = 2, while there is in fact only one ref held by the src/sink which is ringbuffer's parent.
Created attachment 306234 [details] [review] [PATCH] audiobasesrc, audiobasesink: fix invalid refcnt with non-floating ref
Can someone please take a look at the provided patch and maybe apply it to the upstream? This bug blocks a gstreamermm bug 751601.
Not that I want to be an advocate of floating references (I hate them), but in this case I think there is no real problem. If create_ringbuffer() returns a ringbuffer with a non-floating reference, it means that this reference is held by the ringbuffer subclass (transfer none = the caller should not consume any existing reference), so gst_object_ref_sink will add a new reference to be held by the parent and everything is fine.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/202.