Custom sink not getting buffers already in pipeline upon PLAYING->PAUSED sate

My desired goal is to get the buffers that are stuck in the pipeline when PAUSED to get all get to the sink without waiting for PLAYING. The sink is uses collect pads and currently testing with only one pad.

Pipeline:

autovideosrc(avfvideosrc) ! x264enc ! customSink

Here is the custom sink for reference: kvssink

When I change the pipeline state PLAYING->PAUSED, the pipeline immediately stops, and upon setting state back PAUSED->PLAYING, the first few frames that customSink receives are the old ones from just before pausing the element.

I’ve tried several things including ASYNC handling and flushing, and also came across resources suggesting it may involve pull/push modes configuration of elements or the pipeline clock settings. I’ve experimented with just about every possible configuration and order I could come up with, and still not getting the desired behavior. Any guidance would be greatly appreciated.

Relevant gitlab issue: Buffers Stuck When Pausing Live Source with Custom Sink (#3224) · Issues · GStreamer / gstreamer · GitLab