gnomemm r1398 - in gstreamermm/trunk: . gstreamer/src
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1398 - in gstreamermm/trunk: . gstreamer/src
- Date: Sun, 9 Mar 2008 03:28:54 +0000 (GMT)
Author: jaalburqu
Date: Sun Mar 9 03:28:53 2008
New Revision: 1398
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1398&view=rev
Log:
2008-03-08 Josà Alburquerque <jaalburqu svn gnome org>
* gstreamer/src/bin.ccg:
* gstreamer/src/bin.hg: Used WRAP_CREATE() for create() method; Made
add() and remove() not throw exceptions (unsure if need exceptions
presently); Added a needed extra reference to Element in add() method
to avoid warning (see comment in method implementation)
* gstreamer/src/pipeline.ccg:
* gstreamer/src/pipeline.hg: Used _WRAP_CREATE() for create() method
* gstreamer/src/element.hg: Added comment about needing _CTOR_DEFAULT
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/gstreamer/src/bin.ccg
gstreamermm/trunk/gstreamer/src/bin.hg
gstreamermm/trunk/gstreamer/src/element.hg
gstreamermm/trunk/gstreamer/src/pipeline.ccg
gstreamermm/trunk/gstreamer/src/pipeline.hg
Modified: gstreamermm/trunk/gstreamer/src/bin.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bin.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/bin.ccg Sun Mar 9 03:28:53 2008
@@ -27,30 +27,36 @@
namespace Gst
{
-Glib::RefPtr<Bin> Bin::create(const Glib::ustring& name)
-{
- GstElement* bin = gst_bin_new(name.c_str());
- return Glib::wrap((GstBin*) bin);
-}
-
Glib::RefPtr<Bin> Bin::add(const Glib::RefPtr<Element>& element)
{
bool result = gst_bin_add(gobj(), element->gobj());
- if(result)
+ if(result) {
+
+ // When adding an element to a bin, an extra ref is needed because bin
+ // takes ownership of element and wants to unref the element itself when
+ // the bin is destroyed. Without ref, when RefPtr tries to unref the last
+ // reference a warning is issued. Even with extra ref, element is
+ // destroyed when bin unrefs the element when the bin is completely
+ // unreffed and all RefPtrs unref element. Removing element from the bin
+ // will also get rid of the extra ref (gst_bin_remove() does this)
+ element->reference();
+
return Glib::wrap(gobj(), true);
+ }
else
- throw std::runtime_error("Bin '" + get_name() + "' does not want to accept Element '" + element->get_name() + "'");
+ return Glib::RefPtr<Bin>(0);
}
Glib::RefPtr<Bin> Bin::remove(const Glib::RefPtr<Element>& element)
{
bool result = gst_bin_remove(gobj(), element->gobj());
- if(result)
- return Glib::RefPtr<Bin>(this);
+ if(result) {
+ return Glib::wrap(gobj(), true);
+ }
else
- throw std::runtime_error("Bin '" + get_name() + "' does not want to remove Element '" + element->get_name() + "'");
+ return Glib::RefPtr<Bin>(0);
}
} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/bin.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bin.hg (original)
+++ gstreamermm/trunk/gstreamer/src/bin.hg Sun Mar 9 03:28:53 2008
@@ -40,14 +40,11 @@
_IMPLEMENTS_INTERFACE(ChildProxy)
protected:
- _CTOR_DEFAULT
+ _WRAP_CTOR(Bin(const Glib::ustring& name), gst_bin_new)
public:
- //TODO: Why doesn't this use _WRAP_CREATE()?
- static Glib::RefPtr<Bin> create(const Glib::ustring& name);
+ _WRAP_CREATE(const Glib::ustring& name)
- //TODO: Why do these throw exceptions?
- //If there is a good reason for it, document that in comments and doxygen documentation. murrayc.
Glib::RefPtr<Bin> add(const Glib::RefPtr<Element>& element);
Glib::RefPtr<Bin> remove(const Glib::RefPtr<Element>& element);
Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg (original)
+++ gstreamermm/trunk/gstreamer/src/element.hg Sun Mar 9 03:28:53 2008
@@ -84,6 +84,7 @@
_CLASS_GOBJECT(Element, GstElement, GST_ELEMENT, Gst::Object, GstObject)
protected:
+ //Needed for ElementInterfaced derived class
_CTOR_DEFAULT
public:
Modified: gstreamermm/trunk/gstreamer/src/pipeline.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pipeline.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/pipeline.ccg Sun Mar 9 03:28:53 2008
@@ -21,14 +21,3 @@
#include <gst/gstpipeline.h>
#include <gstreamermm/bus.h>
-
-namespace Gst
-{
-
-Glib::RefPtr<Pipeline> Pipeline::create(const Glib::ustring& name)
-{
- GstElement* pipeline = gst_pipeline_new(name.c_str());
- return Glib::wrap((GstPipeline*) pipeline);
-}
-
-} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/pipeline.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pipeline.hg (original)
+++ gstreamermm/trunk/gstreamer/src/pipeline.hg Sun Mar 9 03:28:53 2008
@@ -37,10 +37,10 @@
_CLASS_GOBJECT(Pipeline, GstPipeline, GST_PIPELINE, Bin, GstBin)
protected:
- _CTOR_DEFAULT
+ _WRAP_CTOR(Pipeline(const Glib::ustring& name), gst_pipeline_new)
public:
- static Glib::RefPtr<Pipeline> create(const Glib::ustring& name);
+ _WRAP_CREATE(const Glib::ustring& name)
_WRAP_METHOD(Glib::RefPtr<Bus> get_bus(), gst_pipeline_get_bus)
_WRAP_METHOD(Glib::RefPtr<const Bus> get_bus() const, gst_pipeline_get_bus, constversion)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]