After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 383102 - [0.11] Rethink pad_blocking
[0.11] Rethink pad_blocking
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal major
: 0.11.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-06 19:04 UTC by Sjoerd Simons
Modified: 2011-10-27 14:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sjoerd Simons 2006-12-06 19:04:38 UTC
Hi,

  When a pad is set to blocked (while in push mode) either gst_pad_push or gst_pad_alloc_buffer_full can cause blocked to be signaled. Both function can be called from different thread (notibly when the src pad your blocking is from a queue). Thus something like the following can happen: Thread 1 pushes on the pad, Thread 2 sets the pad to block and waits, Thread 3 does a pad_alloc call and thus signals the blocking (even though Thread 1's push didn't necessarily return yet!)

On a side note, it'd be nice if blocking could also be signalled if there is _no_ dataflow currently.. Especially for live sources where you never (really) know if there will be any dataflow.
Comment 1 Wim Taymans 2006-12-07 11:02:14 UTC
no idea how to fix this...
Comment 2 Wim Taymans 2006-12-15 16:03:45 UTC
Queue (and any other similar element) should serialize push and passthrough of buffer_alloc. For normal elements this is automatic, elements that start a task need additional locking. 
Comment 3 Jan Schmidt 2007-02-27 17:51:48 UTC
While we're on the topic (several months later), it might also be good to set a flag on a pad when it's being chained through and unset it on return, since we need to take locks anyway.
Comment 4 Wim Taymans 2007-07-03 16:40:42 UTC
what would you do with the flag? 
Comment 5 Wim Taymans 2007-07-03 16:41:43 UTC
ah, something else: when you have EOS on the pad and try to block it, it will never block. I think it should.
Comment 6 Tim-Philipp Müller 2009-04-15 22:43:10 UTC
What's up with this?

Maybe someone could add some unit tests that should work but don't work at the moment?
Comment 7 Wim Taymans 2010-12-29 10:53:09 UTC
for 0.11 someone should rethink the pad blocking.
Comment 8 Sebastian Dröge (slomo) 2011-05-18 12:30:36 UTC
Is this actually still a problem in 0.11? (yes, we should rethink and rework pad blocking nonetheless)

Without bufferalloc pad blocks will now only happen for synchronized events and buffers, i.e. can only be triggered from the streaming thread.
Comment 9 Olivier Crête 2011-05-18 14:40:03 UTC
(In reply to comment #8)
> Without bufferalloc pad blocks will now only happen for synchronized events and
> buffers, i.e. can only be triggered from the streaming thread.

Then it's mostly the same as a pad-probe and blocking in there instead of returning.
Comment 10 Wim Taymans 2011-05-18 16:25:17 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > Without bufferalloc pad blocks will now only happen for synchronized events and
> > buffers, i.e. can only be triggered from the streaming thread.
> 
> Then it's mostly the same as a pad-probe and blocking in there instead of
> returning.

I hope at some point that we can implement pad blocking and probes with the same code..
Comment 11 Olivier Crête 2011-05-18 16:45:12 UTC
How is pad blocking in 0.11 different from probes? Apart from having a more annoying API ?
Comment 12 Wim Taymans 2011-05-18 17:03:50 UTC
(In reply to comment #11)
> How is pad blocking in 0.11 different from probes? Apart from having a more
> annoying API ?

What do you mean? probes and pad block are completely different things now.

Probes lets you see the data and events that pass (both upstream and downstream) by triggering a signal. There is limited support for modifying the data. There is no support for blocking the dataflow in a way that works with flushing events. All callbacks are called from the streaming thread. Multiple probes can be installed on a pad.

Pad blocking is to block the dataflow, only works on downstream events. Has support for blocking that works nicely with flushes. There is no support for looking at the blocked item nor modifying it. Only one block can be installed on a pad. The block can be handled from another thread.
Comment 13 Tim-Philipp Müller 2011-10-27 14:28:29 UTC
I think this can be closed now ? Olivier? Wim?
Comment 14 Wim Taymans 2011-10-27 14:41:26 UTC
probes and pad blocking are now the same code. pad_alloc is gone so you don't get weird pad blocks anymore from them. Also there is IDLE probe, which signals you whenever there is no dataflow at all.

This should address all concerns known for pad blocking..