GNOME Bugzilla – Bug 642732
[playbin2] sinks set to READY after activating groups causes bad autoplug-continue decisions
Last modified: 2011-03-23 17:13:39 UTC
I wrote a custom sink element, which accepts "audio/mpeg, mpegversion={2,4}", and it works in these example pipelines. gst-launch filesrc location=/foo.aac ! mysink gst-launch filesrc location=/foo.aac ! gconfaudiosink (configured to use mysink) gst-launch playbin2 uri=file:///foo.aac audio-sink=mysink but, gst-launch playbin2 uri=file:///foo.aac audio-sink=gconfaudiosinnk does not work. I read the (kind of similar) bug report of #642274 and updated the source code to the latest but the above problem remaind. I added some debug print to gstswitchsink.c and then ran with "--gst-debug playsink:5,switchsink:5,gconf:5", which produced the following output. 0:00:00.024510983 21057 0x8a6080 DEBUG switchsink gstswitchsink.c:148:gst_switch_sink_commit_new_kid:<GstSwitchSink@0xaa2060> Replacing kid with fakesink 0:00:00.025330352 21057 0x8a6080 DEBUG switchsink gstswitchsink.c:209:gst_switch_sink_commit_new_kid:<GstSwitchSink@0xaa2060> Creating new ghostpad 0:00:00.025360313 21057 0x8a6080 DEBUG switchsink gstswitchsink.c:213:gst_switch_sink_commit_new_kid:<GstSwitchSink@0xaa2060> done changing child of switchsink 0:00:00.031025894 21057 0x8a6080 DEBUG gconf gstgconfaudiosink.c:232:gst_gconf_switch_profile:<GstGConfAudioSink@0xaa2060> Subscribing to key /system/gstreamer/0.10/default/audiosink for profile 0 0:00:00.031183655 21057 0x8a6080 DEBUG switchsink gstswitchsink.c:266:gst_switch_sink_get_caps:<gconfaudiosink0> no kid set. returns ANY caps. 0:00:00.031205535 21057 0x8a6080 DEBUG switchsink gstswitchsink.c:270:gst_switch_sink_get_caps:<gconfaudiosink0> get caps:ANY WARNING: erroneous pipeline: playbin20 を gconfaudiosink0 へリンクできません(*) (*) failed to link playbin2 to gconfaudiosink0
Are you using gst-plugins-base from GIT? One problem here might be that gconfaudiosink returns ANY caps... could you also get a debug log additionally with playbin2:5?
Created attachment 181307 [details] Debug log of gconfaudiosink in playbin2 > Are you using gst-plugins-base from GIT? No, my box is running Fedora14 and gstreamer-0.10.31 is installed, so the git master failed to configure due to the dependency. but I backported gst-pb/gst/playback to a 0.10.31 based branch, and used this. so basically, they are same I believe. I found that I ran a wrong command to take the debug log, like this: playbin2 uri=file:///foo.ts ! audio-sink=.... sorry for providing the wrong info. My brain must be tired;) This is a re-newed version of debug log from the below command. (it still does not work). playbin2 uri=file:///foo.ts audio-sink=gconfaudiosink --gst-debug playbin:5,playsink:5,switchsink:5,gconf:5
It's playbin2 not playbin
Created attachment 181308 [details] Debug log of gconfaudiosink in playbin2 sorry, I made a mistake again...
The problem is, that gconfaudiosink is in NULL state when the autoplug-continue callback in playbin2 tries to check if the sink supports audio/mpeg. Thus gconfaudiosink returns ANY caps, which is ignored. A solution for this would be to set the state of the audio/video/text sinks to READY *before* the groups in playbin2 are activated. Do you want to make a patch for that?
(In reply to comment #5) > A solution for this would be to set the state of the audio/video/text sinks to > READY *before* the groups in playbin2 are activated. my previous patch on Bug 642433: "[PATCH 2/2] [playbin2] improved the factory selection in auto-plugging" does this (raising the state) DURING autoplug_sort() when retreiving the sink caps. If this patch is applied and configure gconfaudiosink to use alsa-digital-sink, it worked fine, but if configured to use aacspdifsink (which is a bin of aacparse & aac2spdif & alsa), then it failed. I also tried getting the child sink's caps of SwitchSink instead of getting from the template (which is ANY), and failed in vain. I'm not confident in writing the patch, especially regarding the state change and mutual exclusions, but anyway I will try to tackle this.
That's ok, I can take a look at this in the next days then. I don't like the idea of doing state changes in the autoplug-* handlers. It would be better to always set the sinks to READY before the uridecodebins are set to PAUSED (activate_group()). Currently the sinks are set to a higher state than NULL only in playsink after the uridecodebins have completed autoplugging.
Created attachment 181318 [details] [review] [playbin2] improve auto-plugging by setting sink state to READY in advance After applying this patch, playbin2 uri=file:///foo.aac audio-sink=gconfaudiosink (gconf: mysink) is OK. totem is also OK. but Rhythmbox failed to play on mysink.... I'm not sure whether it is because rhythmbox changes audio-profile or not nor whether it is a gconf*sink problem or auto-plugging problem... of course, (gconf: alsa-digital-sink) remains not OK as in Bug 642433.
That's not going to work in all cases and I'm not 100% yet how this should be done at all. Problem is, that your change only works for custom sinks, not for the sinks that are created by playsink automatically. Also it will set all sinks to READY, e.g. no matter if there really is a video stream or not. For playsink created sinks there's also the problem, that they are created after the uridecodebins have finished autoplugging.
Created attachment 181674 [details] [review] [PATCH] [playbin2] collect the caps of sink elements in advance updated the patch. it collects the info. into a hashtable which maps the sink element's typename to the caps in READY state. This is done in initialization and updated when custom-sinks are changed or some plugins are added or removed, before those elements are created and used. The hashtable holds the info not only on custom sinks but on auto-pluggable sinks, and in autoplug_continue_cb() it is used to determine the auto-plugging should be stopped or not. # Sinks with "ANY" caps should not be auto-pluggable, though, I think.
> ....... Also it will set all sinks to > READY, e.g. no matter if there really is a video stream or not. I'm afraid that the same problem occurs in video sinks or text sinks, for example, in the case of gconfvideosink configured to use a custom sink (like VA-API or VDPAU?). but all of these modification might be temporal, until the new playbin2 mentioned by Tim in the comment #1 of Bug 642730 is implemented. so I'm not certain whether we should cover the whole problem or currently confine the modification at minimum (audio only).
There's no timeline for these playbin2 changes AFAIK and no concrete plan what should be changed how :)
Created attachment 182067 [details] [review] [PATCH] [playbin2] collect the caps of sink elements in advance updated the patch, as I found the playbin2 without "audio-sink" property set sometimes crash, due to a NULL lookup of the hash table in update_custom_sink(), which comes from unloaded plugins.
Patches for this and other issues are here: http://git.collabora.co.uk/?p=user/slomo/gst-plugins-base.git;a=shortlog;h=refs/heads/playbin2-compressed Would be great if people could test them, the changes are not really small :)
commit b76efc7f5dcefb43b1ee737fdb5a4511826122c7 Author: Sebastian Dröge <sebastian.droege@collabora.co.uk> Date: Wed Mar 16 15:56:34 2011 +0100 playbin2: Set sinks to READY before checking if it accept caps Fixes bug #642732.