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 618644 - gst_pad_get_caps() Return pad template if parent element is in GST_STATE_NULL
gst_pad_get_caps() Return pad template if parent element is in GST_STATE_NULL
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal blocker
: 0.10.30
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-14 15:29 UTC by Edward Hervey
Modified: 2010-06-15 10:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstpad: Return template caps in get_caps() if parent is in NULL state. (1.26 KB, patch)
2010-05-14 15:29 UTC, Edward Hervey
none Details | Review
GstPad: Add GST_PAD_AWAKE GstPadFlag (8.50 KB, patch)
2010-05-17 13:09 UTC, Edward Hervey
none Details | Review
gstpad: Return pad template in get_caps if pad is not awake (2.10 KB, patch)
2010-05-17 13:09 UTC, Edward Hervey
none Details | Review
GstPad: Add GST_PAD_NEGOTIABLE GstPadFlag (8.77 KB, patch)
2010-05-26 10:27 UTC, Edward Hervey
none Details | Review
gstpad: Return pad template in get_caps if pad is not negotiable (2.13 KB, patch)
2010-05-26 10:27 UTC, Edward Hervey
none Details | Review

Description Edward Hervey 2010-05-14 15:29:04 UTC
Right now gst_pad_get_caps() always calculates the full caps even if the element to which it belongs is in NULL, which is before any actual dataflow or negotiation needs to take place (which will then call again get_caps() through this pad).

The following patch return the pad templates (if any) instead of calling the getcapsfunc when the parent is in GST_STATE_NULL.

This speeds up creating pipelines (since we avoid a lot of useless caps negotiation everytime we link elements) and passes make check on core.
Comment 1 Edward Hervey 2010-05-14 15:29:33 UTC
Created attachment 161069 [details] [review]
gstpad: Return template caps in get_caps() if parent is in NULL state.
Comment 2 Olivier Crête 2010-05-14 15:52:11 UTC
This patch would cause a pipeline like this one to fail when it starts playing instead of failing when it links making it harder to debug:

audiotestsrc ! capsfilter caps="audio/x-raw-float, rate=1000" ! audiorate ! capsfilter caps="audio/x-raw-int, rate=2000" ! fakesink
Comment 3 Edward Hervey 2010-05-14 16:15:27 UTC
agreed, when you build pipelines that fail, you won't get the error anymore at link time but at preroll.

The problem is that we're talking about hundreds of milliseconds (if not whole seconds in some setups) of speed gain setting up pipelines with many elements.

So it comes down to "do we prefer to have faster preroll for virtually all pipelines, or do we prefer to have early abort" ?

BTW, running the pipeline you mention does come up with a pretty good hint (last line):
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0: Could not negotiate format
Additional debug info:
gstbasesrc.c(2757): gst_base_src_start (): /GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0:
Check your filtered caps, if any
Comment 4 Edward Hervey 2010-05-17 13:09:47 UTC
Created attachment 161223 [details] [review]
GstPad: Add GST_PAD_AWAKE GstPadFlag

A pad is 'awake' when its container element is in a state greater
than GST_STATE_READY
Comment 5 Edward Hervey 2010-05-17 13:09:52 UTC
Created attachment 161224 [details] [review]
gstpad: Return pad template in get_caps if pad is not awake
Comment 6 Sebastian Dröge (slomo) 2010-05-17 16:28:29 UTC
Looks good IMHO but the name "awake" doesn't sound right :) If this goes in the patches in bug #618853 need to be updated too to do the same in the get_caps_iterator function.
Comment 7 Edward Hervey 2010-05-18 08:41:08 UTC
I'm open to suggestions for a better designation.
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2010-05-24 10:53:44 UTC
I think we need better documentation of the states a pad can be in, we already have: active, blocked, blocking and linked.

"awake" could be named "negotiatable", if the effect of turning awake of is the same to get_caps, like setting blocked to push/pull.
Comment 9 Edward Hervey 2010-05-26 10:27:21 UTC
Created attachment 162002 [details] [review]
GstPad: Add GST_PAD_NEGOTIABLE GstPadFlag

A pad is 'negotiable' when its container element is in a state greater
than GST_STATE_READY
Comment 10 Edward Hervey 2010-05-26 10:27:26 UTC
Created attachment 162003 [details] [review]
gstpad: Return pad template in get_caps if pad is not negotiable
Comment 11 Edward Hervey 2010-05-26 10:29:15 UTC
(In reply to comment #8)
> I think we need better documentation of the states a pad can be in, we already
> have: active, blocked, blocking and linked.

Seems to be a bit outside of the scope of this bug though, no ?

> 
> "awake" could be named "negotiatable", if the effect of turning awake of is the
> same to get_caps, like setting blocked to push/pull.

Indeed negotiable is better. Updated the patches accordingly.

Any more comments ?
Comment 12 Stefan Sauer (gstreamer, gtkdoc dev) 2010-05-26 15:44:03 UTC
(In reply to comment #11)
> (In reply to comment #8)
> > I think we need better documentation of the states a pad can be in, we already
> > have: active, blocked, blocking and linked.
> 
> Seems to be a bit outside of the scope of this bug though, no ?
> 

Yes, one could call it a pre-requisite. I am just a bit worried about the independent state flags for pads. It is certainly not blocking these patches.


> > 
> > "awake" could be named "negotiatable", if the effect of turning awake of is the
> > same to get_caps, like setting blocked to push/pull.
> 
> Indeed negotiable is better. Updated the patches accordingly.
> 
> Any more comments ?
Comment 13 Sebastian Dröge (slomo) 2010-06-12 10:09:22 UTC
Ok, any chance for getting this in before the next freeze in ~2 days? :)
Comment 14 Tim-Philipp Müller 2010-06-12 11:51:43 UTC
> Ok, any chance for getting this in before the next freeze in ~2 days? :)

Call me overly cautious, but this looks very much like something that shouldn't be committed 2 days before a freeze ;) (I think it will be more than 2 days before we freeze though)
Comment 15 Edward Hervey 2010-06-14 15:11:02 UTC
Ok, I pushed it. I understand being cautious... but I've been using these patches on my 3 systems for the past month installed system-wide and with many apps and having seen any regressions/issues.

If something *really* screwed up comes up ... well.. that's what freezes are for, we can always fix it before the final release.


commit 7460321a600438966d7152ab2b4318be48eadce0
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Mon May 17 15:06:37 2010 +0200

    gstpad: Return pad template in get_caps if pad is not negotiable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618644

commit dc38e75d88bd8921895821f7afed01cab30e46c9
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Mon May 17 15:04:48 2010 +0200

    GstPad: Add GST_PAD_NEGOTIABLE GstPadFlag
    
    A pad is 'negotiable' when its container element is in a state greater
    than GST_STATE_READY
    
    API:gst_pad_is_negotiable
    API:gst_pad_set_negotiable
    API:GST_PAD_NEGOTIABLE
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618644
Comment 16 Stefan Sauer (gstreamer, gtkdoc dev) 2010-06-14 21:10:13 UTC
This causes a regression for me in buzztard:

In the revision before your patch (4a5552bf15924d959fe9faa0292208e98a139a07) things worked fine. I have no other local changes that could cause this.

GStreamer-WARNING **: Pad list returned error on element Filter3_Reverb:tee
aborting...

Program received signal SIGABRT, Aborted.
0xffffe424 in __kernel_vsyscall ()
(gdb) bt
  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/libc.so.6
  • #2 abort
    from /lib/libc.so.6
  • #3 g_logv
    from /usr/lib/libglib-2.0.so.0
  • #4 g_log
    from /usr/lib/libglib-2.0.so.0
  • #5 gst_pad_proxy_getcaps
    at gstutils.c line 2749
  • #6 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #7 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #8 gst_pad_get_caps
    at gstpad.c line 2307
  • #9 gst_pad_peer_get_caps
    at gstpad.c line 2392
  • #10 gst_queue_getcaps
    at gstqueue.c line 470
  • #11 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #12 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #13 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #14 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #15 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #16 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #17 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #18 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #19 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #20 getcaps_fold_func
    at gstutils.c line 2642
  • #21 gst_iterator_fold
    at gstiterator.c line 549
  • #22 gst_pad_proxy_getcaps
    at gstutils.c line 2700
  • #23 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #24 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #25 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #26 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #27 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #28 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #29 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #30 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #31 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #32 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #33 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #34 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #35 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #36 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #37 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #38 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #39 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #40 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #41 gst_pad_get_caps
    at gstpad.c line 2307
  • #42 gst_pad_peer_get_caps
    at gstpad.c line 2392
  • #43 gst_adder_sink_getcaps
    at gstadder.c line 197
  • #44 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #45 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #46 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #47 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #48 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #49 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #50 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #51 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #52 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #53 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #54 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #55 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #56 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #57 getcaps_fold_func
    at gstutils.c line 2642
  • #58 gst_iterator_fold
    at gstiterator.c line 549
  • #59 gst_pad_proxy_getcaps
    at gstutils.c line 2700
  • #60 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #61 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #62 gst_pad_get_caps
    at gstpad.c line 2307
  • #63 gst_pad_peer_get_caps
    at gstpad.c line 2392
  • #64 gst_queue_getcaps
    at gstqueue.c line 470
  • #65 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #66 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #67 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #68 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #69 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #70 gst_proxy_pad_do_getcaps
    at gstghostpad.c line 208
  • #71 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #72 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #73 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #74 getcaps_fold_func
    at gstutils.c line 2642
  • #75 gst_iterator_fold
    at gstiterator.c line 549
  • #76 gst_pad_proxy_getcaps
    at gstutils.c line 2700
  • #77 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #78 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #79 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #80 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #81 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #82 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #83 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #84 gst_base_transform_getcaps
    at gstbasetransform.c line 630
  • #85 gst_pad_get_caps_unlocked
    at gstpad.c line 2198
  • #86 gst_pad_get_caps_reffed
    at gstpad.c line 2282
  • #87 gst_pad_peer_get_caps_reffed
    at gstpad.c line 2349
  • #88 gst_base_src_default_negotiate
    at gstbasesrc.c line 2590
  • #89 gst_base_src_negotiate
    at gstbasesrc.c line 2655
  • #90 gst_base_src_start
    at gstbasesrc.c line 2738
  • #91 gst_base_src_activate_push
    at gstbasesrc.c line 2910
  • #92 gst_pad_activate_push
    at gstpad.c line 924
  • #93 gst_pad_activate_default
    at gstpad.c line 591
  • #94 gst_pad_set_active
    at gstpad.c line 680
  • #95 activate_pads
    at gstelement.c line 2626
  • #96 gst_iterator_fold
    at gstiterator.c line 549
  • #97 iterator_activate_fold_with_resync
    at gstelement.c line 2658
  • #98 gst_element_pads_activate
    at gstelement.c line 2740
  • #99 gst_element_change_state_func
    at gstelement.c line 2820
  • #100 gst_base_src_change_state
    at gstbasesrc.c line 3053
  • #101 gst_element_change_state
    at gstelement.c line 2542
  • #102 gst_element_set_state_func
    at gstelement.c line 2498
  • #103 gst_element_set_state
    at gstelement.c line 2399
  • #104 gst_bin_element_set_state
    at gstbin.c line 2121
  • #105 gst_bin_change_state_func
    at gstbin.c line 2420
  • #106 gst_element_change_state
    at gstelement.c line 2542
  • #107 gst_element_set_state_func
    at gstelement.c line 2498
  • #108 gst_element_set_state
    at gstelement.c line 2399
  • #109 gst_bin_element_set_state
    at gstbin.c line 2121
  • #110 gst_bin_change_state_func
  • #111 gst_pipeline_change_state
    at gstpipeline.c line 475
  • #112 gst_element_change_state
    at gstelement.c line 2542
  • #113 gst_element_continue_state
    at gstelement.c line 2216
  • #114 gst_element_change_state
    at gstelement.c line 2579
  • #115 gst_element_set_state_func
    at gstelement.c line 2498
  • #116 gst_element_set_state
    at gstelement.c line 2399
  • #117 bt_song_play
    at song.c line 742
  • #118 on_toolbar_play_clicked
    at main-toolbar.c line 211
  • #119 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #120 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #121 ??
    from /usr/lib/libgobject-2.0.so.0
  • #122 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #123 g_signal_emit_by_name
    from /usr/lib/libgobject-2.0.so.0
  • #124 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #125 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #126 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #127 ??
    from /usr/lib/libgobject-2.0.so.0
  • #128 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #129 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #130 gtk_button_clicked
    from /usr/lib/libgtk-x11-2.0.so.0
  • #131 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #132 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #133 ??
    from /usr/lib/libgobject-2.0.so.0
  • #134 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #135 ??
    from /usr/lib/libgobject-2.0.so.0
  • #136 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #137 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #138 gtk_button_released
    from /usr/lib/libgtk-x11-2.0.so.0
  • #139 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #140 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #141 ??
    from /usr/lib/libgobject-2.0.so.0
  • #142 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #143 ??
    from /usr/lib/libgobject-2.0.so.0
  • #144 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #145 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #146 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #147 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #148 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #149 ??
    from /usr/lib/libgdk-x11-2.0.so.0
  • #150 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #151 ??
    from /usr/lib/libglib-2.0.so.0
  • #152 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #153 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #154 bt_edit_application_run_ui
    at edit-application.c line 199
  • #155 bt_edit_application_load_and_run
    at edit-application.c line 526
  • #156 main
    at bt-edit.c line 185

Comment 17 Edward Hervey 2010-06-15 06:56:54 UTC
There indeed seems to be an issue regarding GstGhostPad/GstProxyPad. I'm looking into this.
Comment 18 Edward Hervey 2010-06-15 08:42:10 UTC
I can reproduce this via the camerabin test in -bad. Will investigate further.
Comment 19 Edward Hervey 2010-06-15 09:55:03 UTC
commit 4a11063768e904c3c026e2f4fcd0fb156321ad05
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Tue Jun 15 11:48:26 2010 +0200

    Revert "GstPad: Add GST_PAD_NEGOTIABLE GstPadFlag"
    
    This reverts commit dc38e75d88bd8921895821f7afed01cab30e46c9.
    
    boom

commit 3df54c45bff7f206dbf833b5c4e4aaaaac0b2f9a
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Tue Jun 15 11:48:17 2010 +0200

    Revert "gstpad: Return pad template in get_caps if pad is not negotiable"
    
    This reverts commit 7460321a600438966d7152ab2b4318be48eadce0.
    
    crack

commit 19334dbb85f968dd085fa8059ee7c6d7ad50b294
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Tue Jun 15 11:48:07 2010 +0200

    Revert "pad: fix comment"
    
    This reverts commit 8e92cb4a7d56cdfa4674315c64b58c1b1b9d8208.
    
    whatever...

commit 27a58ed70ded862d3d8823f9f50ed7b45a6b064e
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Tue Jun 15 11:47:57 2010 +0200

    Revert "element: only clear negotiable when going to NULL"
    
    This reverts commit 8f5ec1f737c3b37538b2307aef160d9d21f1c422.
    
    bleeeeh
Comment 20 Sebastian Dröge (slomo) 2010-06-15 10:03:59 UTC
What's exactly the problem? That ghostpads have as parent their proxypad but are still negotiatable?

IMHO instead of reverting all this you should make a pad negotiable by default if it has no parent or no GstElement parent.
Comment 21 Edward Hervey 2010-06-15 10:15:39 UTC
The problem in the end wasn't really because of ghostpads (making them negotiable by default did indeed fix that).

The real problem was regarding linking.

If the template of a pad is ANY (like for capsfilter)... then you could link together streams that were guaranteed never to negotiate (videotestsrc ! capsfilter which you'd link to alsasink for example).

One alternative idea to solve the performance issue would be to have a gst_pad_link that doesn't do the expensive checks. Modifying the existing gst_pad_link to do that doesn't help though (we end up in the same situation as above).