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 642732 - [playbin2] sinks set to READY after activating groups causes bad autoplug-continue decisions
[playbin2] sinks set to READY after activating groups causes bad autoplug-con...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.33
Other Linux
: Normal minor
: 0.10.33
Assigned To: Sebastian Dröge (slomo)
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-02-19 07:30 UTC by Akihiro Tsukada
Modified: 2011-03-23 17:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Debug log of gconfaudiosink in playbin2 (14.19 KB, text/plain)
2011-02-19 08:17 UTC, Akihiro Tsukada
  Details
Debug log of gconfaudiosink in playbin2 (22.79 KB, text/plain)
2011-02-19 08:38 UTC, Akihiro Tsukada
  Details
[playbin2] improve auto-plugging by setting sink state to READY in advance (2.90 KB, patch)
2011-02-19 14:17 UTC, Akihiro Tsukada
none Details | Review
[PATCH] [playbin2] collect the caps of sink elements in advance (14.00 KB, patch)
2011-02-23 08:30 UTC, Akihiro Tsukada
none Details | Review
[PATCH] [playbin2] collect the caps of sink elements in advance (14.28 KB, patch)
2011-02-28 08:06 UTC, Akihiro Tsukada
rejected Details | Review

Description Akihiro Tsukada 2011-02-19 07:30:10 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
Comment 1 Sebastian Dröge (slomo) 2011-02-19 07:34:12 UTC
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?
Comment 2 Akihiro Tsukada 2011-02-19 08:17:25 UTC
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
Comment 3 Sebastian Dröge (slomo) 2011-02-19 08:31:11 UTC
It's playbin2 not playbin
Comment 4 Akihiro Tsukada 2011-02-19 08:38:07 UTC
Created attachment 181308 [details]
Debug log of gconfaudiosink in playbin2

sorry, I made a mistake again...
Comment 5 Sebastian Dröge (slomo) 2011-02-19 09:44:32 UTC
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?
Comment 6 Akihiro Tsukada 2011-02-19 12:19:25 UTC
(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.
Comment 7 Sebastian Dröge (slomo) 2011-02-19 12:27:28 UTC
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.
Comment 8 Akihiro Tsukada 2011-02-19 14:17:33 UTC
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.
Comment 9 Sebastian Dröge (slomo) 2011-02-19 14:42:25 UTC
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.
Comment 10 Akihiro Tsukada 2011-02-23 08:30:15 UTC
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.
Comment 11 Akihiro Tsukada 2011-02-23 08:51:30 UTC
> ....... 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).
Comment 12 Sebastian Dröge (slomo) 2011-02-23 09:04:06 UTC
There's no timeline for these playbin2 changes AFAIK and no concrete plan what should be changed how :)
Comment 13 Akihiro Tsukada 2011-02-28 08:06:25 UTC
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.
Comment 14 Sebastian Dröge (slomo) 2011-03-16 17:25:13 UTC
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 :)
Comment 15 Sebastian Dröge (slomo) 2011-03-23 17:13:39 UTC
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.