audiobasesrc, audiobasesink: incorrect ringbuffer refcount when create_ringbuffer returns a non-floating ref
Submitted by Michał Wróbel
Link to original bug (#751606)
Description
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.