[gstreamermm: 80/167] [peper0] Pad::chain and Pad::push functions corrected
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 80/167] [peper0] Pad::chain and Pad::push functions corrected
- Date: Tue, 3 Sep 2013 19:25:48 +0000 (UTC)
commit de7ed051fbffe2ca5a8034f4077a8fac79c9ff87
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date: Tue Jul 30 13:22:54 2013 +0200
[peper0] Pad::chain and Pad::push functions corrected
gstreamer/src/pad.ccg | 21 +++++++++++++++------
gstreamer/src/pad.hg | 6 +++---
2 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/gstreamer/src/pad.ccg b/gstreamer/src/pad.ccg
index b1d881a..66ef3db 100644
--- a/gstreamer/src/pad.ccg
+++ b/gstreamer/src/pad.ccg
@@ -133,10 +133,15 @@ FlowReturn Pad::get_range(guint64 offset, guint size, Glib::RefPtr<Gst::Buffer>&
return FlowReturn(result);
}
-FlowReturn Pad::push(const Glib::RefPtr<Gst::Buffer>& buffer)
+FlowReturn Pad::push(Glib::RefPtr<Gst::Buffer>& buffer)
{
- buffer->reference();
- return FlowReturn(gst_pad_push(gobj(), buffer->gobj()));
+ GstBuffer *buffer_gobj = buffer->gobj();
+ /* gst_pad_push takes ownership of given "buffer". It is recommended (for performance reasons) that the
buffer given to gst_pad_push() has
+ * only one reference, since in other cases it will be copied whenever "make_writable" will be called.
+ */
+ buffer->reference(); //allocate additional ref for gst_pad_push()
+ buffer.reset(); //take away buffer from the caller
+ return FlowReturn(gst_pad_push(gobj(), buffer_gobj));
}
bool Pad::push_event(const Glib::RefPtr<Gst::Event>& event)
@@ -169,9 +174,11 @@ bool Pad::query_duration(Format& format) const
return gst_pad_query_duration(const_cast<GstPad*>(gobj()), (GstFormat)format, 0);
}
-FlowReturn Pad::chain(const Glib::RefPtr<Gst::Buffer>& buffer)
+FlowReturn Pad::chain(Glib::RefPtr<Gst::Buffer>& buffer)
{
- buffer->reference();
+ GstBuffer *buffer_gobj = buffer->gobj();
+ buffer->reference(); //hold reference for gst_pad_chain()
+ buffer.reset(); //free caller's reference
return FlowReturn(gst_pad_chain(gobj(), buffer->gobj()));
}
@@ -187,9 +194,11 @@ GstFlowReturn Pad_Chain_gstreamermm_callback(GstPad* pad, GstObject* parent, Gst
try
{
+ Glib::RefPtr<Buffer> buffer_wrapped = Glib::wrap(buffer, false); //manage object
+
return static_cast<GstFlowReturn>(
pad_wrapper->slot_chain(Glib::wrap(pad, true), //take copy
- Glib::wrap(buffer, false) //manage object
+ buffer_wrapped
));
}
catch(...)
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index caa7b2e..9f319c5 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -123,7 +123,7 @@ public:
*/
typedef sigc::slot< bool, const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::MiniObject>& > SlotData;
- typedef sigc::slot< Gst::FlowReturn, const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::Buffer>& >
SlotChain;
+ typedef sigc::slot< Gst::FlowReturn, const Glib::RefPtr<Gst::Pad>&, Glib::RefPtr<Gst::Buffer>& > SlotChain;
/** Creates a new pad with the given name in the given direction.
*
@@ -253,7 +253,7 @@ public:
* @param buffer The Gst::Buffer to push.
* @return A Gst::FlowReturn from the peer pad. MT safe.
*/
- FlowReturn push(const Glib::RefPtr<Gst::Buffer>& buffer);
+ FlowReturn push(Glib::RefPtr<Gst::Buffer>& buffer);
_IGNORE(gst_pad_push)
// This method is written manually because an extra ref is necessary
@@ -366,7 +366,7 @@ public:
_WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<const Gst::Pad> > get_internal_links_default() const,
gst_pad_get_internal_links_default)
// This method is written manually because an extra ref is necessary
- FlowReturn chain(const Glib::RefPtr<Gst::Buffer>& buffer);
+ FlowReturn chain(Glib::RefPtr<Gst::Buffer>& buffer);
_IGNORE(gst_pad_chain)
_WRAP_METHOD(bool pause_task() , gst_pad_pause_task)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]