Bug 107445 - [gstreamer] MediaPlayerPrivateGStreamer should take ownership of the playbin
Summary: [gstreamer] MediaPlayerPrivateGStreamer should take ownership of the playbin
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on: 107554
Blocks: 107544
  Show dependency treegraph
 
Reported: 2013-01-21 06:38 PST by Chris Dumez
Modified: 2013-01-22 06:21 PST (History)
7 users (show)

See Also:


Attachments
Patch (2.13 KB, patch)
2013-01-21 06:42 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (1.99 KB, patch)
2013-01-21 07:01 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch using a smart pointer (alternative) (22.83 KB, patch)
2013-01-22 02:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2013-01-21 06:38:28 PST
In gstreamer 1.0, gst_element_factory_make() now returns a floating reference [1]. MediaPlayerPrivateGStreamer calls gst_element_factory_make() to create the playbin object but does not take ownership of the object. As a consequence, the object keeps floating until it is unref'd in the MediaPlayerPrivateGStreamer destructor.

We should call gst_object_ref_sink() on the playbin object returned by gst_element_factory_make() to effectively take ownership of it.

[1] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElementFactory.html#gst-element-factory-make
Comment 1 Chris Dumez 2013-01-21 06:42:33 PST
Created attachment 183772 [details]
Patch
Comment 2 Philippe Normand 2013-01-21 06:43:52 PST
How about using an adopted GRefPtr<GstElement>?
Comment 3 Chris Dumez 2013-01-21 06:47:56 PST
(In reply to comment #2)
> How about using an adopted GRefPtr<GstElement>?

Hmm. We cannot adopt since it is floating.

Did I understand correctly that you want to make m_playBin a GRefPtr<GstElement> ? If so, then we need to adopt with gstreamer 0.10 and *not* adopt with gstreamer 1.0. I'm fine with that. However, I will likely need to replace uses to m_playBin everywhere by m_playBin.get(), right?
Comment 4 Philippe Normand 2013-01-21 06:52:05 PST
Comment on attachment 183772 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=183772&action=review

Right, Christophe... Well, Martin are you OK with this patch?

> Source/WebCore/ChangeLog:17
> +We should call gst_object_ref_sink() on the playbin object returned by gst_element_factory_make() to effectively take ownership of it.

Left over?
Comment 5 Chris Dumez 2013-01-21 06:53:39 PST
Comment on attachment 183772 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=183772&action=review

>> Source/WebCore/ChangeLog:17
>> +We should call gst_object_ref_sink() on the playbin object returned by gst_element_factory_make() to effectively take ownership of it.
> 
> Left over?

Oops.
Comment 6 Chris Dumez 2013-01-21 06:59:55 PST
(In reply to comment #2)
> How about using an adopted GRefPtr<GstElement>?

Well, I do not mind using a smart pointer if you prefer. However, keep in mind this involves more changes.

Also note that we are already doing the following a few lines below:

// Take ownership.
gst_object_ref_sink(m_videoSinkBin);
Comment 7 Chris Dumez 2013-01-21 07:01:38 PST
Created attachment 183778 [details]
Patch

Fix changelog (not using smart pointer yet).
Comment 8 Chris Dumez 2013-01-22 02:57:48 PST
Created attachment 183949 [details]
Patch using a smart pointer (alternative)
Comment 9 Philippe Normand 2013-01-22 04:30:59 PST
Comment on attachment 183949 [details]
Patch using a smart pointer (alternative)

LGTM!
Comment 10 WebKit Review Bot 2013-01-22 04:56:51 PST
Comment on attachment 183949 [details]
Patch using a smart pointer (alternative)

Clearing flags on attachment: 183949

Committed r140414: <http://trac.webkit.org/changeset/140414>
Comment 11 WebKit Review Bot 2013-01-22 04:56:55 PST
All reviewed patches have been landed.  Closing bug.
Comment 12 Chris Dumez 2013-01-22 06:19:54 PST
Comment on attachment 183949 [details]
Patch using a smart pointer (alternative)

View in context: https://bugs.webkit.org/attachment.cgi?id=183949&action=review

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:1797
> +    // In gstreamer 1.0, gst_element_factory_make returns a floating

Based on the results on the Qt bots, it seems like the gstreamer 0.10 doc may be wrong and gst_element_factory_make() is returning a floating reference there as well :(
I'll upload a fix soon.