Re: Why is the reference count of sink element 0 when it is disconnected from a pipeline

cfd new via gstreamer-devel <[email protected]> Fri, 6 Oct 2023 16:07:24 +0000 (UTC)
Newsgroups gmane.comp.video.gstreamer.devel
Message-ID <[email protected]>
 Another weird thing happened when I switched the audio devices too quickly. The ref count of the sink was 6 once. This is very strange.
   Joe

    On Friday, October 6, 2023, 12:00:42 p.m. EDT, cfd new via gstreamer-devel <[email protected]> wrote:  
 
  
Wait, Nicolas. I have a few other elements. After the pipeline is unlinked and a new sink is created, I link all elements again.Basically, only the sink is replaced. Why can other elements still be used if their ref counts are 0 as well?
   Joe
    On Friday, October 6, 2023, 10:22:58 a.m. EDT, cfd new <[email protected]> wrote:  
 
  Thanks a lot, Nicolas. Good to know. Will move to discourse.gstreamer.org
| 
| 
| 
|  |  |

 |

 |
| 
|  | 
GStreamer Discourse

GStreamer Project and Community related discussions
 |

 |

 |



    Joe

    On Friday, October 6, 2023, 07:45:39 a.m. EDT, Nicolas Dufresne via gstreamer-devel <[email protected]> wrote:  
 
 Hi,
Be aware that we now have a forum at discourse.gstreamer.org which is getting more activity.

Le jeu. 5 oct. 2023, 20 h 15, cfd new via gstreamer-devel <[email protected]> a écrit :

I have a audio pipeline with a sink. When I switch audio devices, I want to replace the sink only. What I did in the code are,1. set pipeline state to NULL
1. disconnect sink element from the pipeline2. unref it <===problem here: reference count is 0 and can not unref it. Why?
3. create a new sink element and link it to pipeline4. set pipeline state to PLAYING
   the pipeline works fine with the new sink. But why can not the old sink be deleted?

When you create an element from factory, it's created with a floating ref. As a side effect, when the element get added to the pipeline, the pipeline will get the floating ref, effectively passing ownership. In your case, you have dropped the last reference when you removed the element from the bin/pipeline. Use ref_sink if you want to prevent that.
Nicolas

 
   thanks for your help,
   Joe